<!DOCTYPE html>
<html lang="en" class="svg no-js">
<head>
    <meta charset="utf-8" />
    <!--[if IE ]>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="Language" content="en">

    <title>MySQL :: MySQL 8.0 Reference Manual :: 13.1.9 ALTER TABLE Syntax</title>
    <link rel="stylesheet" media="all" href="css/main-20190125.min.css" />
            <link rel="stylesheet" media="all" href="css/docs-20190125.min.css" />
    
    
    <link rel="stylesheet" media="print" href="css/print-20190125.min.css" />

    
    
    
    
            <link rel="contents" href="index.html" title="MySQL 8.0 Reference Manual" />
<link rel="start" href="index.html" title="MySQL 8.0 Reference Manual" />
<link rel="prev" href="alter-server.html" title="13.1.8 ALTER SERVER Syntax" />
<link rel="next" href="alter-table-partition-operations.html?ff=nopfpls" title="13.1.9.1 ALTER TABLE Partition Operations" />
<link rel="up" href="sql-syntax-data-definition.html" title="13.1 Data Definition Statements" />

    
    <link rel="shortcut icon" href="favicon.ico" />
    <script>(function(H){ H.className=H.className.replace(/\bno-js\b/,'js') })(document.documentElement)</script>
    <script src="js/site-20181120.min.js"></script>

    
    
    
    <!--[if lt IE 9]>
        <script src="https://labs.mysql.com/common/js/polyfills/html5shiv-printshiv-3.7.2.min.js"></script>
        <script src="https://labs.mysql.com/common/js/polyfills/respond-1.4.2.min.js"></script>
    <![endif]-->
        <!--[if IE 9]>
        <style>#docs-sidebar-toc { box-sizing: content-box; }</style>
    <![endif]-->
    </head>

<body class="no-sidebar full-page dev">
<div class="page-wrapper">
    <header>

                        <a href="https://dev.mysql.com/" aria-label="Home" title="MySQL" id="l1-home-link"></a>
        
        <div id="l1-nav-container">
            <div id="l1-line1">
                <div id="l1-auth-links">
                    <a href="https://www.mysql.com/about/contact/"><b>Contact MySQL</b></a>
                    <span id="l1-contact-separator">&nbsp;|&nbsp;</span>
                    <span id="l1-contact-separator-br"><br /></span>
                                             <a href="https://dev.mysql.com/auth/login/?dest=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F8.0%2Fen%2Falter-table.html">Login</a> &nbsp;|&nbsp;
                         <a href="https://dev.mysql.com/auth/register/">Register</a>
                                    </div>
                <div id="l1-lhs">
                    <div id="l1-slogan">
                        The world's most popular open source database
                    </div>
                    <div id="l1-search-box">
                        <form id="l1-search-form" method="get" action="https://www.oracle.com/search/results">
                        <input type="hidden" name="cat" value="mysql" />
                        <input type="hidden" name="Ntk" value="SI-ALL5" />
                        <input id="l1-search-input" type="search" class="icon-search" placeholder="Search" aria-label="Search" name="Ntt" />
                        </form>
                    </div>
                </div>
            </div>
            <div id="l1-line2">
                <div class="social-icons">
                    <a aria-label="Join us on Facebook" title="Join us on Facebook" href="http://www.facebook.com/mysql"><span class="icon-facebook"></span></a>
                    <a aria-label="Follow us on Twitter" title="Follow us on Twitter" href="https://twitter.com/mysql"><span class="icon-twitter"></span></a>
                    <a aria-label="Follow us on LinkedIn" title="Follow us on LinkedIn" href="https://www.linkedin.com/company/mysql"><span class="icon-linkedin"></span></a>
                    <a aria-label="Visit our YouTube channel" title="Visit our YouTube channel" href="http://www.youtube.com/mysqlchannel"><span class="icon-youtube"></span></a>
                </div>
                <ul id="l1-nav">
                    <li>
                        <a href="https://www.mysql.com/"><!-- <span class="icon-sakila"></span>  -->MySQL.com</a>
                    </li><li>
                        <a href="https://www.mysql.com/downloads/"><!-- <span class="icon-download-thin"></span>  -->Downloads</a>
                    </li><li class="active">
                        <a href="/doc/"><!-- <span class="icon-books"></span>  -->Documentation</a>
                    </li><li>
                        <a href="/"><!-- <span class="icon-code"></span>  -->Developer Zone</a>
                    </li>                </ul>
            </div>
        </div>
        <div id="sub-header">
            <div id="l2-nav-container">
                <div id="l2-nav-toggle">
                    <span class="icon-three-bars"></span>
                </div>
                                                                                        <a class="button nav-button-3" href="/"><span class="icon-code"></span> Developer Zone</a>
                                                                                                                                    <a class="button nav-button-2" href="https://www.mysql.com/downloads/"><span class="icon-download-thin"></span> Downloads</a>
                                                                                                <a class="button nav-button-1" href="https://www.mysql.com/"><span class="icon-sakila"></span> MySQL.com</a>
                                                                        <div id="l2-search-toggle">
                    <span class="icon-search"></span>
                </div>
                <div id="l2-site-icon">
                                                                                                                                                                                                    <span class="icon-books"></span>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        </div>
                <div id="l1-section-title">
                    <span id="l1-section-label">
                        <a href="/doc/">Documentation</a>
                    </span>
                </div>
                <nav>
                    

<ul id="l2-nav">
            	<li class="active"><a class="active " href="/doc/refman/en/">MySQL Server</a>
    			</li>
	        	<li class=""><a  href="/doc/index-enterprise.html">MySQL Enterprise</a>
    			</li>
	        	<li class=""><a  href="/doc/workbench/en/">Workbench</a>
    			</li>
	        	<li class=""><a  href="/doc/en/mysql-innodb-cluster-userguide.html">InnoDB Cluster</a>
    			</li>
	        	<li class=""><a  href="/doc/index-cluster.html">MySQL NDB Cluster</a>
    			</li>
	        	<li class=""><a  href="/doc/index-connectors.html">Connectors</a>
    			</li>
	        	<li class=" last"><a  href="/doc/index-other.html">More</a>
    			</li>
	                        <li class="other-section"><a href="https://www.mysql.com/">MySQL.com</a></li>
                            <li class="other-section"><a href="https://www.mysql.com/downloads/">Downloads</a></li>
                                        <li class="other-section"><a href="/">Developer Zone</a></li>
            </ul>
                </nav>
            </div>
            <div id="l3-search-container"></div>
            <div id="top-orange"><span id="section-nav">Section Menu: &nbsp; </span></div>
        </div>
    </header>
        <div id="page">
                        <div role="main" id="main">

            
                
            
<div>
    <div id="docs-sidebar-toc" class="">
    <div id="docs-toc-inner">
        <div class="docs-sidebar-header" id="docs-nav-header">
            <a class="docs-show-hide-nav" id="docs-hide-nav" href="" title="Hide Sidebar" aria-label="Hide Sidebar"><span class="icon-arrow-small-left"></span></a>
            <div class="docs-nav-links">
                                    
    <a href="alter-server.html"
        aria-label="Previous" title="Previous: ALTER SERVER Syntax"><span
        class="icon-chevron-left"></span></a>
<a href="index.html" aria-label="Start" title="Start"><span class="icon-book-open"></span></a>
        <a aria-label="Up" href="sql-syntax-data-definition.html" title="Up: Data Definition Statements"><span class="icon-chevron-up"></span></a>
    <a href="alter-table-partition-operations.html" aria-label="Next"
        title="Next: ALTER TABLE Partition Operations"><span
        class="icon-chevron-right"></span></a>
                            </div>
        </div>
                    
<div id="docs-sidebar-search-container">
    <div id="docs-sidebar-search-box">
        <form method="get" action="/mysql-manual/search-page">
            <input type="hidden" name="d" id="d" value="201" />
            <input type="hidden" name="p" id="p" value="1" />
            <input type="text" name="keyword" id="q" title="Search this Manual"
                value=""
                style="color: #bbb;"
                onfocus=""
                onblur="" />

            <button class="docs-sidebar-search-btn" aria-label="Search" title="Search" type="submit">
                <span class="icon-search"></span>
            </button>
        </form>
    </div>
</div>
                <div class="docs-sidebar-nav">
            <a class="docs-icon-home" href="/doc/"><span class="icon-home"></span>Documentation Home</a><hr />
            <div class="docs-sidebar-mtitle">MySQL 8.0 Reference Manual</div>
            <nav class="doctoc" id="doc-201">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="preface.html">Preface and Legal Notices</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="introduction.html">General Information</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="installing.html">Installing and Upgrading MySQL</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="tutorial.html">Tutorial</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="programs.html">MySQL Programs</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="server-administration.html">MySQL Server Administration</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="security.html">Security</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="backup-and-recovery.html">Backup and Recovery</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="optimization.html">Optimization</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="language-structure.html">Language Structure</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="charset.html">Character Sets, Collations, Unicode</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="data-types.html">Data Types</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="functions.html">Functions and Operators</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-down"></span></a></div><div class="docs-sidebar-nav-link"><a href="sql-syntax.html">SQL Statement Syntax</a></div></div>                        <div class="docs-submenu">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-down"></span></a></div><div class="docs-sidebar-nav-link"><a href="sql-syntax-data-definition.html">Data Definition Statements</a></div></div>                        <div class="docs-submenu">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="atomic-ddl.html">Atomic Data Definition Statement Support</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-database.html">ALTER DATABASE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-event.html">ALTER EVENT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-function.html">ALTER FUNCTION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-instance.html">ALTER INSTANCE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-logfile-group.html">ALTER LOGFILE GROUP Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-procedure.html">ALTER PROCEDURE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-server.html">ALTER SERVER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-down"></span></a></div><div class="docs-sidebar-nav-link current"><a href="alter-table.html">ALTER TABLE Syntax</a></div></div>                        <div class="docs-submenu">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-table-partition-operations.html">ALTER TABLE Partition Operations</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-table-generated-columns.html">ALTER TABLE and Generated Columns</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-table-examples.html">ALTER TABLE Examples</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-tablespace.html">ALTER TABLESPACE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-view.html">ALTER VIEW Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-database.html">CREATE DATABASE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-event.html">CREATE EVENT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-function.html">CREATE FUNCTION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-index.html">CREATE INDEX Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-logfile-group.html">CREATE LOGFILE GROUP Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-procedure.html">CREATE PROCEDURE and CREATE FUNCTION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-server.html">CREATE SERVER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-spatial-reference-system.html">CREATE SPATIAL REFERENCE SYSTEM Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="create-table.html">CREATE TABLE Syntax</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-table-statement-retention.html">CREATE TABLE Statement Retention</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-table-files.html">Files Created by CREATE TABLE</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-temporary-table.html">CREATE TEMPORARY TABLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-table-like.html">CREATE TABLE ... LIKE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-table-select.html">CREATE TABLE ... SELECT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-table-foreign-keys.html">Using FOREIGN KEY Constraints</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-table-check-constraints.html">CHECK Constraints</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="silent-column-changes.html">Silent Column Specification Changes</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-table-generated-columns.html">CREATE TABLE and Generated Columns</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-table-secondary-indexes.html">Secondary Indexes and Generated Columns</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-table-ndb-table-comment-options.html">Setting NDB_TABLE Options</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-tablespace.html">CREATE TABLESPACE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-trigger.html">CREATE TRIGGER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-view.html">CREATE VIEW Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-database.html">DROP DATABASE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-event.html">DROP EVENT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-function.html">DROP FUNCTION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-index.html">DROP INDEX Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-logfile-group.html">DROP LOGFILE GROUP Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-procedure.html">DROP PROCEDURE and DROP FUNCTION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-server.html">DROP SERVER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-spatial-reference-system.html">DROP SPATIAL REFERENCE SYSTEM Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-table.html">DROP TABLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-tablespace.html">DROP TABLESPACE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-trigger.html">DROP TRIGGER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-view.html">DROP VIEW Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="rename-table.html">RENAME TABLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="truncate-table.html">TRUNCATE TABLE Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="sql-syntax-data-manipulation.html">Data Manipulation Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="call.html">CALL Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="delete.html">DELETE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="do.html">DO Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="handler.html">HANDLER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="import-table.html">IMPORT TABLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="insert.html">INSERT Syntax</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="insert-select.html">INSERT ... SELECT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="insert-on-duplicate.html">INSERT ... ON DUPLICATE KEY UPDATE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="insert-delayed.html">INSERT DELAYED Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="load-data.html">LOAD DATA Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="load-xml.html">LOAD XML Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="replace.html">REPLACE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="select.html">SELECT Syntax</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="select-into.html">SELECT ... INTO Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="join.html">JOIN Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="union.html">UNION Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="subqueries.html">Subquery Syntax</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="scalar-subqueries.html">The Subquery as Scalar Operand</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="comparisons-using-subqueries.html">Comparisons Using Subqueries</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="any-in-some-subqueries.html">Subqueries with ANY, IN, or SOME</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="all-subqueries.html">Subqueries with ALL</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="row-subqueries.html">Row Subqueries</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="exists-and-not-exists-subqueries.html">Subqueries with EXISTS or NOT EXISTS</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="correlated-subqueries.html">Correlated Subqueries</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="derived-tables.html">Derived Tables</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="lateral-derived-tables.html">Lateral Derived Tables</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="subquery-errors.html">Subquery Errors</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="optimizing-subqueries.html">Optimizing Subqueries</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="rewriting-subqueries.html">Rewriting Subqueries as Joins</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="update.html">UPDATE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="with.html">WITH Syntax (Common Table Expressions)</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="sql-syntax-transactions.html">Transactional and Locking Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="commit.html">START TRANSACTION, COMMIT, and ROLLBACK Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="cannot-roll-back.html">Statements That Cannot Be Rolled Back</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="implicit-commit.html">Statements That Cause an Implicit Commit</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="savepoint.html">SAVEPOINT, ROLLBACK TO SAVEPOINT, and RELEASE SAVEPOINT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="lock-instance-for-backup.html">LOCK INSTANCE FOR BACKUP and UNLOCK INSTANCE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="lock-tables.html">LOCK TABLES and UNLOCK TABLES Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="set-transaction.html">SET TRANSACTION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="xa.html">XA Transactions</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="xa-statements.html">XA Transaction SQL Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="xa-states.html">XA Transaction States</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="sql-syntax-replication.html">Replication Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="replication-master-sql.html">SQL Statements for Controlling Master Servers</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="purge-binary-logs.html">PURGE BINARY LOGS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="reset-master.html">RESET MASTER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="set-sql-log-bin.html">SET sql_log_bin Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="replication-slave-sql.html">SQL Statements for Controlling Slave Servers</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="change-master-to.html">CHANGE MASTER TO Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="change-replication-filter.html">CHANGE REPLICATION FILTER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="master-pos-wait.html">MASTER_POS_WAIT() Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="reset-slave.html">RESET SLAVE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="set-global-sql-slave-skip-counter.html">SET GLOBAL sql_slave_skip_counter Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="start-slave.html">START SLAVE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="stop-slave.html">STOP SLAVE Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="replication-group-sql.html">SQL Statements for Controlling Group Replication</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="start-group-replication.html">START GROUP_REPLICATION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="stop-group-replication.html">STOP GROUP_REPLICATION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="group-replication-functions-for-new-primary.html">Function which Configures Group Replication Primary</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="group-replication-functions-for-mode.html">Functions which Configure the Group Replication Mode</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="group-replication-functions-for-maximum-consensus.html">Functions to Inspect and Configure the Maximum Consensus Instances of a
        Group</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="group-replication-functions-for-communication-protocol.html">Functions to Inspect and Set the Group Replication Communication
Protocol Version</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="sql-syntax-prepared-statements.html">Prepared SQL Statement Syntax</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="prepare.html">PREPARE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="execute.html">EXECUTE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="deallocate-prepare.html">DEALLOCATE PREPARE Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="sql-syntax-compound-statements.html">Compound-Statement Syntax</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="begin-end.html">BEGIN ... END Compound-Statement Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="statement-labels.html">Statement Label Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="declare.html">DECLARE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="stored-program-variables.html">Variables in Stored Programs</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="declare-local-variable.html">Local Variable DECLARE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="local-variable-scope.html">Local Variable Scope and Resolution</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="flow-control-statements.html">Flow Control Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="case.html">CASE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="if.html">IF Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="iterate.html">ITERATE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="leave.html">LEAVE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="loop.html">LOOP Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="repeat.html">REPEAT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="return.html">RETURN Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="while.html">WHILE Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="cursors.html">Cursors</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="close.html">Cursor CLOSE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="declare-cursor.html">Cursor DECLARE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="fetch.html">Cursor FETCH Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="open.html">Cursor OPEN Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="condition-handling.html">Condition Handling</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="declare-condition.html">DECLARE ... CONDITION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="declare-handler.html">DECLARE ... HANDLER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="get-diagnostics.html">GET DIAGNOSTICS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="resignal.html">RESIGNAL Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="signal.html">SIGNAL Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="handler-scope.html">Scope Rules for Handlers</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="diagnostics-area.html">The MySQL Diagnostics Area</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="conditions-and-parameters.html">Condition Handling and OUT or INOUT Parameters</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="sql-syntax-server-administration.html">Database Administration Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="account-management-sql.html">Account Management Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-user.html">ALTER USER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-role.html">CREATE ROLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-user.html">CREATE USER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-role.html">DROP ROLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-user.html">DROP USER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="grant.html">GRANT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="rename-user.html">RENAME USER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="revoke.html">REVOKE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="set-default-role.html">SET DEFAULT ROLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="set-password.html">SET PASSWORD Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="set-role.html">SET ROLE Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="resource-group-sql.html">Resource Group Management Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="alter-resource-group.html">ALTER RESOURCE GROUP Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-resource-group.html">CREATE RESOURCE GROUP Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-resource-group.html">DROP RESOURCE GROUP Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="set-resource-group.html">SET RESOURCE GROUP Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="table-maintenance-sql.html">Table Maintenance Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="analyze-table.html">ANALYZE TABLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="check-table.html">CHECK TABLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="checksum-table.html">CHECKSUM TABLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="optimize-table.html">OPTIMIZE TABLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="repair-table.html">REPAIR TABLE Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="component-sql.html">Component, Plugin, and User-Defined Function Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="create-function-udf.html">CREATE FUNCTION Syntax for User-Defined Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="drop-function-udf.html">DROP FUNCTION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="install-component.html">INSTALL COMPONENT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="install-plugin.html">INSTALL PLUGIN Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="uninstall-component.html">UNINSTALL COMPONENT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="uninstall-plugin.html">UNINSTALL PLUGIN Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="set-statement.html">SET Syntax</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="set-variable.html">SET Syntax for Variable Assignment</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="set-character-set.html">SET CHARACTER SET Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="set-names.html">SET NAMES Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="show.html">SHOW Syntax</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-binary-logs.html">SHOW BINARY LOGS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-binlog-events.html">SHOW BINLOG EVENTS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-character-set.html">SHOW CHARACTER SET Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-collation.html">SHOW COLLATION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-columns.html">SHOW COLUMNS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-create-database.html">SHOW CREATE DATABASE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-create-event.html">SHOW CREATE EVENT Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-create-function.html">SHOW CREATE FUNCTION Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-create-procedure.html">SHOW CREATE PROCEDURE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-create-table.html">SHOW CREATE TABLE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-create-trigger.html">SHOW CREATE TRIGGER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-create-user.html">SHOW CREATE USER Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-create-view.html">SHOW CREATE VIEW Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-databases.html">SHOW DATABASES Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-engine.html">SHOW ENGINE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-engines.html">SHOW ENGINES Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-errors.html">SHOW ERRORS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-events.html">SHOW EVENTS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-function-code.html">SHOW FUNCTION CODE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-function-status.html">SHOW FUNCTION STATUS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-grants.html">SHOW GRANTS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-index.html">SHOW INDEX Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-master-status.html">SHOW MASTER STATUS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-open-tables.html">SHOW OPEN TABLES Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-plugins.html">SHOW PLUGINS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-privileges.html">SHOW PRIVILEGES Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-procedure-code.html">SHOW PROCEDURE CODE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-procedure-status.html">SHOW PROCEDURE STATUS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-processlist.html">SHOW PROCESSLIST Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-profile.html">SHOW PROFILE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-profiles.html">SHOW PROFILES Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-relaylog-events.html">SHOW RELAYLOG EVENTS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-slave-hosts.html">SHOW SLAVE HOSTS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-slave-status.html">SHOW SLAVE STATUS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-status.html">SHOW STATUS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-table-status.html">SHOW TABLE STATUS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-tables.html">SHOW TABLES Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-triggers.html">SHOW TRIGGERS Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-variables.html">SHOW VARIABLES Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="show-warnings.html">SHOW WARNINGS Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="other-administrative-sql.html">Other Administrative Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="binlog.html">BINLOG Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="cache-index.html">CACHE INDEX Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="flush.html">FLUSH Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="kill.html">KILL Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="load-index.html">LOAD INDEX INTO CACHE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="reset.html">RESET Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="reset-persist.html">RESET PERSIST Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="restart.html">RESTART Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="shutdown.html">SHUTDOWN Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="sql-syntax-utility.html">Utility Statements</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="describe.html">DESCRIBE Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="explain.html">EXPLAIN Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="help.html">HELP Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="use.html">USE Syntax</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="data-dictionary.html">MySQL Data Dictionary</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="innodb-storage-engine.html">The InnoDB Storage Engine</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="storage-engines.html">Alternative Storage Engines</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="replication.html">Replication</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="group-replication.html">Group Replication</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="mysql-shell-userguide.html">MySQL Shell</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="document-store.html">Using MySQL as a Document Store</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="mysql-innodb-cluster-userguide.html">InnoDB Cluster</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="mysql-cluster.html">MySQL NDB Cluster 8.0</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="partitioning.html">Partitioning</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="stored-objects.html">Stored Objects</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="information-schema.html">INFORMATION_SCHEMA Tables</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="performance-schema.html">MySQL Performance Schema</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="sys-schema.html">MySQL sys Schema</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="connectors-apis.html">Connectors and APIs</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="extending-mysql.html">Extending MySQL</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="mysql-enterprise.html">MySQL Enterprise Edition</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="workbench.html">MySQL Workbench</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="faqs.html">MySQL 8.0 Frequently Asked Questions</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="error-handling.html">Errors, Error Codes, and Common Problems</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="restrictions.html">Restrictions and Limits</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="indexes.html">Indexes</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="glossary.html">MySQL Glossary</a></div></div>                    </li>
        </ul>
                            </nav>
        </div>

        
<a class="docs-sidebar-section" href=""><span class="icon-related"></span>
    <span class="text">Related Documentation</span></a>
<div class="docs-sidebar-accordian open">
    <div class="text">
        <a href="/doc/relnotes/mysql/8.0/en/">MySQL 8.0 Release Notes</a><br />
        <a href="/doc/dev/mysql-server/latest/">MySQL 8.0 Source Code Documentation</a><br />
        </div>
</div>

    <a class="docs-sidebar-section" href=""><span class="icon-download-thin"></span>
        <span class="text">
            Download
                            this Manual
                    </span>
    </a>
    <div class="docs-sidebar-accordian open">
        <div class="text">
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.pdf">PDF (US Ltr)</a>
            - 46.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.a4.pdf">PDF (A4)</a>
            - 46.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-ref-manual-8.0-en-pdf-1-20190611.noarch.rpm">PDF (RPM)</a>
            - 41.5Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.html-chapter.tar.gz">HTML Download (TGZ)</a>
            - 10.6Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.html-chapter.zip">HTML Download (Zip)</a>
            - 10.6Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-ref-manual-8.0-en-html-chapter-1-20190611.noarch.rpm">HTML Download (RPM)</a>
            - 9.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.man-gpl.tar.gz">Man Pages (TGZ)</a>
            - 220.4Kb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.man-gpl.zip">Man Pages (Zip)</a>
            - 325.8Kb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-8.0.info.gz">Info (Gzip)</a>
            - 4.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-8.0.info.zip">Info (Zip)</a>
            - 4.1Mb<br />
                    </div>
    </div>

<a class="docs-sidebar-section" href=""><span class="icon-book"></span>
    <span class="text">Excerpts from this Manual</span></a>
<div class="docs-sidebar-accordian">
    <div class="text">
                <a href="/doc/mysql-backup-excerpt/8.0/en/">MySQL Backup and Recovery</a><br />
                <a href="/doc/mysql-g11n-excerpt/8.0/en/">MySQL Globalization</a><br />
                <a href="/doc/mysql-infoschema-excerpt/8.0/en/">MySQL Information Schema</a><br />
                <a href="/doc/mysql-installation-excerpt/8.0/en/">MySQL Installation Guide</a><br />
                <a href="/doc/mysql-security-excerpt/8.0/en/">Security in MySQL</a><br />
                <a href="/doc/mysql-startstop-excerpt/8.0/en/">Starting and Stopping MySQL</a><br />
                <a href="/doc/mysql-linuxunix-excerpt/8.0/en/">MySQL and Linux/Unix</a><br />
                <a href="/doc/mysql-windows-excerpt/8.0/en/">MySQL and Windows</a><br />
                <a href="/doc/mysql-osx-excerpt/8.0/en/">MySQL and OS X</a><br />
                <a href="/doc/mysql-solaris-excerpt/8.0/en/">MySQL and Solaris</a><br />
                <a href="/doc/mysql-sourcebuild-excerpt/8.0/en/">Building MySQL from Source</a><br />
                <a href="/doc/mysql-reslimits-excerpt/8.0/en/">MySQL Restrictions and Limitations</a><br />
                <a href="/doc/mysql-partitioning-excerpt/8.0/en/">MySQL Partitioning</a><br />
                <a href="/doc/mysql-secure-deployment-guide/8.0/en/">MySQL Secure Deployment Guide</a><br />
                <a href="/doc/mysql-tutorial-excerpt/8.0/en/">MySQL Tutorial</a><br />
                <a href="/doc/mysql-perfschema-excerpt/8.0/en/">MySQL Performance Schema</a><br />
                <a href="/doc/mysql-replication-excerpt/8.0/en/">MySQL Replication</a><br />
                <a href="/doc/mysql-repo-excerpt/8.0/en/">Using the MySQL Yum Repository</a><br />
            </div>
</div>

        <br /><span id="wkr"><br /></span>
    </div>
    </div>

    <div id="docs-main" class="has-toc">
    <div id="docs-main-inner">

                <div class="right" id="docs-version-nav">
            <a href="" id="docs-version-nav-toggle">version 8.0
            <span class="icon-chevron-down"></span></a>
            <div id="docs-version-list">
                                                                                            <a                         href="/doc/refman/5.7/en/alter-table.html">
                        5.7
                                            </a><br />
                                                                            <a                         href="/doc/refman/5.6/en/alter-table.html">
                        5.6
                                            </a><br />
                                                                            <a                         href="/doc/refman/5.5/en/alter-table.html">
                        5.5
                                            </a><br />
                                                                        <div id="docs-version-nav-lang">
                                                                                                                                                    <a                                     href="/doc/refman/5.6/ja/alter-table.html">
                                    5.6&nbsp;
                                                                            Japanese
                                                                    </a><br />
                                                                                            </div>
                            </div>
        </div>
        
        <div id="docs-show-nav" class="left hidden" style="margin-right: 15px;">
            <a class="docs-show-hide-nav" href="" aria-label="Show Sidebar"
                title="Show Sidebar"><span class="icon-arrow-small-right"></span></a>
        </div>

                        <div id="docs-breadcrumbs">
            <a href="/doc/refman/8.0/en/">MySQL 8.0 Reference Manual</a> &nbsp;/&nbsp;
                            <span id="breadcrumbs-link"><a href="" id="show-breadcrumbs">...</a> &nbsp;/&nbsp;</span>
                <span class="hidden" id="hidden-breadcrumbs">
                                                        <a href="sql-syntax.html">SQL Statement Syntax</a> &nbsp;/&nbsp;
                                                            <a href="sql-syntax-data-definition.html">Data Definition Statements</a> &nbsp;/&nbsp;
                                                                                        </span>
                                        ALTER TABLE Syntax
                                    </div>
        
        <div id="docs-body">
        
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name="alter-table"></a>13.1.9 ALTER TABLE Syntax</h3>

</div>

</div>

</div>
<div class="toc">
<p><small>[<a href="#" class="tocdetail" onclick="toggle('tocdetail-0'); return false;" onkeypress="if (event.keyCode == 13) { toggle('tocdetail-0'); return false;}">+/-</a>]</small></p>
<dl id="tocdetail-0"><dt><span class="section"><a href="alter-table-partition-operations.html">13.1.9.1 ALTER TABLE Partition Operations</a></span></dt><dt><span class="section"><a href="alter-table-generated-columns.html">13.1.9.2 ALTER TABLE and Generated Columns</a></span></dt><dt><span class="section"><a href="alter-table-examples.html">13.1.9.3 ALTER TABLE Examples</a></span></dt></dl>
</div>
<a class="indexterm" name="idm139663179196640"></a><a class="indexterm" name="idm139663179195568"></a><a class="indexterm" name="idm139663179194080"></a><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">ALTER TABLE <em class="replaceable">tbl_name</em>
    [<em class="replaceable">alter_specification</em> [, <em class="replaceable">alter_specification</em>] ...]
    [<em class="replaceable">partition_options</em>]

<em class="replaceable">alter_specification</em>:
    <em class="replaceable">table_options</em>
  | ADD [COLUMN] <em class="replaceable">col_name</em> <em class="replaceable">column_definition</em>
        [FIRST | AFTER <em class="replaceable">col_name</em>]
  | ADD [COLUMN] (<em class="replaceable">col_name</em> <em class="replaceable">column_definition</em>,...)
  | ADD {INDEX|KEY} [<em class="replaceable">index_name</em>]
        [<em class="replaceable">index_type</em>] (<em class="replaceable">key_part</em>,...) [<em class="replaceable">index_option</em>] ...
  | ADD {FULLTEXT|SPATIAL} [INDEX|KEY] [<em class="replaceable">index_name</em>]
        (<em class="replaceable">key_part</em>,...) [<em class="replaceable">index_option</em>] ...
  | ADD [CONSTRAINT [<em class="replaceable">symbol</em>]] PRIMARY KEY
        [<em class="replaceable">index_type</em>] (<em class="replaceable">key_part</em>,...)
        [<em class="replaceable">index_option</em>] ...
  | ADD [CONSTRAINT [<em class="replaceable">symbol</em>]] UNIQUE [INDEX|KEY]
        [<em class="replaceable">index_name</em>] [<em class="replaceable">index_type</em>] (<em class="replaceable">key_part</em>,...)
        [<em class="replaceable">index_option</em>] ...
  | ADD [CONSTRAINT [<em class="replaceable">symbol</em>]] FOREIGN KEY
        [<em class="replaceable">index_name</em>] (<em class="replaceable">col_name</em>,...)
        <em class="replaceable">reference_definition</em>
  | ADD <em class="replaceable">check_constraint_definition</em>
  | DROP CHECK <em class="replaceable">symbol</em>
  | ALTER CHECK <em class="replaceable">symbol</em> [NOT] ENFORCED
  | ALGORITHM [=] {DEFAULT|INSTANT|INPLACE|COPY}
  | ALTER [COLUMN] <em class="replaceable">col_name</em> {SET DEFAULT <em class="replaceable">literal</em> | DROP DEFAULT}
  | ALTER INDEX <em class="replaceable">index_name</em> {VISIBLE | INVISIBLE}
  | CHANGE [COLUMN] <em class="replaceable">old_col_name</em> <em class="replaceable">new_col_name</em> <em class="replaceable">column_definition</em>
        [FIRST|AFTER <em class="replaceable">col_name</em>]
  | [DEFAULT] CHARACTER SET [=] <em class="replaceable">charset_name</em> [COLLATE [=] <em class="replaceable">collation_name</em>]
  | CONVERT TO CHARACTER SET <em class="replaceable">charset_name</em> [COLLATE <em class="replaceable">collation_name</em>]
  | {DISABLE|ENABLE} KEYS
  | {DISCARD|IMPORT} TABLESPACE
  | DROP [COLUMN] <em class="replaceable">col_name</em>
  | DROP {INDEX|KEY} <em class="replaceable">index_name</em>
  | DROP PRIMARY KEY
  | DROP FOREIGN KEY <em class="replaceable">fk_symbol</em>
  | FORCE
  | LOCK [=] {DEFAULT|NONE|SHARED|EXCLUSIVE}
  | MODIFY [COLUMN] <em class="replaceable">col_name</em> <em class="replaceable">column_definition</em>
        [FIRST | AFTER <em class="replaceable">col_name</em>]
  | ORDER BY <em class="replaceable">col_name</em> [, <em class="replaceable">col_name</em>] ...
  | RENAME COLUMN <em class="replaceable">old_col_name</em> TO <em class="replaceable">new_col_name</em>
  | RENAME {INDEX|KEY} <em class="replaceable">old_index_name</em> TO <em class="replaceable">new_index_name</em>
  | RENAME [TO|AS] <em class="replaceable">new_tbl_name</em>
  | {WITHOUT|WITH} VALIDATION
  | ADD PARTITION (<em class="replaceable">partition_definition</em>)
  | DROP PARTITION <em class="replaceable">partition_names</em>
  | DISCARD PARTITION {<em class="replaceable">partition_names</em> | ALL} TABLESPACE
  | IMPORT PARTITION {<em class="replaceable">partition_names</em> | ALL} TABLESPACE
  | TRUNCATE PARTITION {<em class="replaceable">partition_names</em> | ALL}
  | COALESCE PARTITION <em class="replaceable">number</em>
  | REORGANIZE PARTITION <em class="replaceable">partition_names</em> INTO (<em class="replaceable">partition_definitions</em>)
  | EXCHANGE PARTITION <em class="replaceable">partition_name</em> WITH TABLE <em class="replaceable">tbl_name</em> [{WITH|WITHOUT} VALIDATION]
  | ANALYZE PARTITION {<em class="replaceable">partition_names</em> | ALL}
  | CHECK PARTITION {<em class="replaceable">partition_names</em> | ALL}
  | OPTIMIZE PARTITION {<em class="replaceable">partition_names</em> | ALL}
  | REBUILD PARTITION {<em class="replaceable">partition_names</em> | ALL}
  | REPAIR PARTITION {<em class="replaceable">partition_names</em> | ALL}
  | REMOVE PARTITIONING

<em class="replaceable">key_part</em>: {<em class="replaceable">col_name</em> [(<em class="replaceable">length</em>)] | (<em class="replaceable">expr</em>)} [ASC | DESC]

<em class="replaceable">index_type</em>:
    USING {BTREE | HASH}

<em class="replaceable">index_option</em>:
    KEY_BLOCK_SIZE [=] <em class="replaceable">value</em>
  | <em class="replaceable">index_type</em>
  | WITH PARSER <em class="replaceable">parser_name</em>
  | COMMENT '<em class="replaceable">string</em>'
  | {VISIBLE | INVISIBLE}

<em class="replaceable">check_constraint_definition</em>:
    [CONSTRAINT [<em class="replaceable">symbol</em>]] CHECK (<em class="replaceable">expr</em>) [[NOT] ENFORCED]

<em class="replaceable">table_options</em>:
    <em class="replaceable">table_option</em> [[,] <em class="replaceable">table_option</em>] ...

<em class="replaceable">table_option</em>:
    AUTO_INCREMENT [=] <em class="replaceable">value</em>
  | AVG_ROW_LENGTH [=] <em class="replaceable">value</em>
  | [DEFAULT] CHARACTER SET [=] <em class="replaceable">charset_name</em>
  | CHECKSUM [=] {0 | 1}
  | [DEFAULT] COLLATE [=] <em class="replaceable">collation_name</em>
  | COMMENT [=] '<em class="replaceable">string</em>'
  | COMPRESSION [=] {'ZLIB'|'LZ4'|'NONE'}
  | CONNECTION [=] '<em class="replaceable">connect_string</em>'
  | {DATA|INDEX} DIRECTORY [=] '<em class="replaceable">absolute path to directory</em>'
  | DELAY_KEY_WRITE [=] {0 | 1}
  | ENCRYPTION [=] {'Y' | 'N'}
  | ENGINE [=] <em class="replaceable">engine_name</em>
  | INSERT_METHOD [=] { NO | FIRST | LAST }
  | KEY_BLOCK_SIZE [=] <em class="replaceable">value</em>
  | MAX_ROWS [=] <em class="replaceable">value</em>
  | MIN_ROWS [=] <em class="replaceable">value</em>
  | PACK_KEYS [=] {0 | 1 | DEFAULT}
  | PASSWORD [=] '<em class="replaceable">string</em>'
  | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}
  | STATS_AUTO_RECALC [=] {DEFAULT|0|1}
  | STATS_PERSISTENT [=] {DEFAULT|0|1}
  | STATS_SAMPLE_PAGES [=] <em class="replaceable">value</em>
  | TABLESPACE <em class="replaceable">tablespace_name</em> [STORAGE {DISK|MEMORY}]
  | UNION [=] (<em class="replaceable">tbl_name</em>[,<em class="replaceable">tbl_name</em>]...)

<em class="replaceable">partition_options</em>:
    (see CREATE TABLE options)</code></pre><p>
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> changes the structure
      of a table. For example, you can add or delete columns, create or
      destroy indexes, change the type of existing columns, or rename
      columns or the table itself. You can also change characteristics
      such as the storage engine used for the table or the table
      comment.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          To use <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>, you need
          <a class="link" href="privileges-provided.html#priv_alter"><code class="literal">ALTER</code></a>,
          <a class="link" href="privileges-provided.html#priv_create"><code class="literal">CREATE</code></a>, and
          <a class="link" href="privileges-provided.html#priv_insert"><code class="literal">INSERT</code></a> privileges for the
          table. Renaming a table requires
          <a class="link" href="privileges-provided.html#priv_alter"><code class="literal">ALTER</code></a> and
          <a class="link" href="privileges-provided.html#priv_drop"><code class="literal">DROP</code></a> on the old table,
          <a class="link" href="privileges-provided.html#priv_alter"><code class="literal">ALTER</code></a>,
          <a class="link" href="privileges-provided.html#priv_create"><code class="literal">CREATE</code></a>, and
          <a class="link" href="privileges-provided.html#priv_insert"><code class="literal">INSERT</code></a> on the new table.
        </p></li><li class="listitem"><p>
          Following the table name, specify the alterations to be made.
          If none are given, <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>
          does nothing.
        </p></li><li class="listitem"><p>
          The syntax for many of the permissible alterations is similar
          to clauses of the <a class="link" href="create-table.html" title="13.1.20 CREATE TABLE Syntax"><code class="literal">CREATE TABLE</code></a>
          statement. <em class="replaceable"><code>column_definition</code></em>
          clauses use the same syntax for <code class="literal">ADD</code> and
          <code class="literal">CHANGE</code> as for <a class="link" href="create-table.html" title="13.1.20 CREATE TABLE Syntax"><code class="literal">CREATE
          TABLE</code></a>. For more information, see
          <a class="xref" href="create-table.html" title="13.1.20 CREATE TABLE Syntax">Section 13.1.20, “CREATE TABLE Syntax”</a>.
        </p></li><li class="listitem"><p>
          The word <code class="literal">COLUMN</code> is optional and can be
          omitted, except for <code class="literal">RENAME COLUMN</code> (to
          distinguish a column-renaming operation from the
          <code class="literal">RENAME</code> table-renaming operation).
        </p></li><li class="listitem"><p>
          Multiple <code class="literal">ADD</code>, <code class="literal">ALTER</code>,
          <code class="literal">DROP</code>, and <code class="literal">CHANGE</code> clauses
          are permitted in a single <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER
          TABLE</code></a> statement, separated by commas. This is a
          MySQL extension to standard SQL, which permits only one of
          each clause per <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>
          statement. For example, to drop multiple columns in a single
          statement, do this:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t2 DROP COLUMN c, DROP COLUMN d;</code></pre></li><li class="listitem"><p>
          If a storage engine does not support an attempted
          <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> operation, a
          warning may result. Such warnings can be displayed with
          <a class="link" href="show-warnings.html" title="13.7.6.40 SHOW WARNINGS Syntax"><code class="literal">SHOW WARNINGS</code></a>. See
          <a class="xref" href="show-warnings.html" title="13.7.6.40 SHOW WARNINGS Syntax">Section 13.7.6.40, “SHOW WARNINGS Syntax”</a>. For information on
          troubleshooting <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>,
          see <a class="xref" href="alter-table-problems.html" title="B.4.6.1 Problems with ALTER TABLE">Section B.4.6.1, “Problems with ALTER TABLE”</a>.
        </p></li><li class="listitem"><p>
          For information about generated columns, see
          <a class="xref" href="alter-table-generated-columns.html" title="13.1.9.2 ALTER TABLE and Generated Columns">Section 13.1.9.2, “ALTER TABLE and Generated Columns”</a>.
        </p></li><li class="listitem"><p>
          For usage examples, see
          <a class="xref" href="alter-table-examples.html" title="13.1.9.3 ALTER TABLE Examples">Section 13.1.9.3, “ALTER TABLE Examples”</a>.
        </p></li><li class="listitem"><p>
          With the <a class="link" href="mysql-info.html" title="28.7.7.36 mysql_info()"><code class="literal">mysql_info()</code></a> C API
          function, you can find out how many rows were copied by
          <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>. See
          <a class="xref" href="mysql-info.html" title="28.7.7.36 mysql_info()">Section 28.7.7.36, “mysql_info()”</a>.
</p><a class="indexterm" name="idm139663179092224"></a></li></ul>
</div>
<p>
      There are several additional aspects to the <code class="literal">ALTER
      TABLE</code> statement, described under the following topics in
      this section:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-options" title="Table Options">Table Options</a></p></li><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-performance" title="Performance and Space Requirements">Performance and Space Requirements</a></p></li><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-concurrency" title="Concurrency Control">Concurrency Control</a></p></li><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-add-drop-column" title="Adding and Dropping Columns">Adding and Dropping Columns</a></p></li><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-redefine-column" title="Renaming, Redefining, and Reordering Columns">Renaming, Redefining, and Reordering Columns</a></p></li><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-index" title="Primary Keys and Indexes">Primary Keys and Indexes</a></p></li><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-foreign-key" title="Foreign Keys and Other Constraints">Foreign Keys and Other Constraints</a></p></li><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-character-set" title="Changing the Character Set">Changing the Character Set</a></p></li><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-discard-import" title="Discarding and Importing InnoDB Tablespaces">Discarding and Importing InnoDB Tablespaces</a></p></li><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-row-order" title="Row Order for MyISAM Tables">Row Order for MyISAM Tables</a></p></li><li class="listitem"><p><a class="xref" href="alter-table.html#alter-table-partition-options" title="Partitioning Options">Partitioning Options</a></p></li></ul>
</div>
<h4><a name="alter-table-options"></a>Table Options</h4>
<p>
      <em class="replaceable"><code>table_options</code></em> signifies table options
      of the kind that can be used in the <a class="link" href="create-table.html" title="13.1.20 CREATE TABLE Syntax"><code class="literal">CREATE
      TABLE</code></a> statement, such as <code class="literal">ENGINE</code>,
      <code class="literal">AUTO_INCREMENT</code>,
      <code class="literal">AVG_ROW_LENGTH</code>, <code class="literal">MAX_ROWS</code>,
      <code class="literal">ROW_FORMAT</code>, or <code class="literal">TABLESPACE</code>.
    </p><p>
      For descriptions of all table options, see
      <a class="xref" href="create-table.html" title="13.1.20 CREATE TABLE Syntax">Section 13.1.20, “CREATE TABLE Syntax”</a>. However,
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> ignores <code class="literal">DATA
      DIRECTORY</code> and <code class="literal">INDEX DIRECTORY</code> when
      given as table options. <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>
      permits them only as partitioning options, and requires that you
      have the <code class="literal">FILE</code> privilege.
    </p><p>
      Use of table options with <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER
      TABLE</code></a> provides a convenient way of altering single table
      characteristics. For example:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          If <code class="literal">t1</code> is currently not an
          <code class="literal">InnoDB</code> table, this statement changes its
          storage engine to <code class="literal">InnoDB</code>:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 ENGINE = InnoDB;</code></pre>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>
              See <a class="xref" href="converting-tables-to-innodb.html" title="15.6.1.3 Converting Tables from MyISAM to InnoDB">Section 15.6.1.3, “Converting Tables from MyISAM to InnoDB”</a> for
              considerations when switching tables to the
              <code class="literal">InnoDB</code> storage engine.
            </p></li><li class="listitem"><p>
              When you specify an <code class="literal">ENGINE</code> clause,
              <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> rebuilds the
              table. This is true even if the table already has the
              specified storage engine.
            </p></li><li class="listitem"><p>
              Running <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER
              TABLE <em class="replaceable"><code>tbl_name</code></em>
              ENGINE=INNODB</code></a> on an existing
              <code class="literal">InnoDB</code> table performs a
              <span class="quote">“<span class="quote">null</span>”</span> <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER
              TABLE</code></a> operation, which can be used to defragment
              an <code class="literal">InnoDB</code> table, as described in
              <a class="xref" href="innodb-file-defragmenting.html" title="15.11.4 Defragmenting a Table">Section 15.11.4, “Defragmenting a Table”</a>. Running
              <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE
              <em class="replaceable"><code>tbl_name</code></em> FORCE</code></a> on an
              <code class="literal">InnoDB</code> table performs the same
              function.
            </p></li><li class="listitem"><p>
              <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE
              <em class="replaceable"><code>tbl_name</code></em>
              ENGINE=INNODB</code></a> and
              <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE
              <em class="replaceable"><code>tbl_name</code></em> FORCE</code></a> use
              <a class="link" href="innodb-online-ddl.html" title="15.12 InnoDB and Online DDL">online DDL</a>. For
              more information, see <a class="xref" href="innodb-online-ddl.html" title="15.12 InnoDB and Online DDL">Section 15.12, “InnoDB and Online DDL”</a>.
            </p></li><li class="listitem"><p>
              The outcome of attempting to change the storage engine of
              a table is affected by whether the desired storage engine
              is available and the setting of the
              <a class="link" href="sql-mode.html#sqlmode_no_engine_substitution"><code class="literal">NO_ENGINE_SUBSTITUTION</code></a>
              SQL mode, as described in <a class="xref" href="sql-mode.html" title="5.1.11 Server SQL Modes">Section 5.1.11, “Server SQL Modes”</a>.
            </p></li><li class="listitem"><p>
              To prevent inadvertent loss of data,
              <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> cannot be used
              to change the storage engine of a table to
              <code class="literal">MERGE</code> or <code class="literal">BLACKHOLE</code>.
</p></li></ul>
</div>
</li><li class="listitem"><p>
          To change the <code class="literal">InnoDB</code> table to use
          compressed row-storage format:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 ROW_FORMAT = COMPRESSED;</code></pre></li><li class="listitem"><p>
          The <code class="literal">ENCRYPTION</code> clause enables or disables
          page-level data encryption for an <code class="literal">InnoDB</code>
          table. A keyring plugin must be installed and configured to
          enable encryption.
        </p><p>
          If the
          <a class="link" href="server-system-variables.html#sysvar_table_encryption_privilege_check"><code class="literal">table_encryption_privilege_check</code></a>
          variable is enabled, the
          <a class="link" href="privileges-provided.html#priv_table-encryption-admin"><code class="literal">TABLE_ENCRYPTION_ADMIN</code></a>
          privilege is required to use an <code class="literal">ENCRYPTION</code>
          clause with a setting that differs from the default schema
          encryption setting.
        </p><p>
          Prior to MySQL 8.0.16, the <code class="literal">ENCRYPTION</code>
          clause was only supported when altering tables residing in
          file-per-table tablespaces. As of MySQL 8.0.16, the
          <code class="literal">ENCRYPTION</code> clause is also supported for
          tables residing in general tablespaces.
        </p><p>
          For tables that reside in general tablespaces, table and
          tablespace encryption must match.
        </p><p>
          Altering table encryption by moving a table to a different
          tablespace or changing the storage engine is not permitted
          without explicitly specifying an <code class="literal">ENCRYPTION</code>
          clause.
        </p><p>
          As of MySQL 8.0.16, specifying an
          <code class="literal">ENCRYPTION</code> clause with a value other than
          <code class="literal">'N'</code> or <code class="literal">''</code> is not
          permitted if the table uses storage engine that does not
          support encryption. Previously, the clause was accepted.
          Attempting to create a table without an
          <code class="literal">ENCRYPTION</code> clause in an encryption-enabled
          schema using a storage engine that does not support encryption
          is also not permitted.
        </p><p>
          For more information, see
          <a class="xref" href="innodb-tablespace-encryption.html" title="15.6.3.9 InnoDB Data-at-Rest Encryption">Section 15.6.3.9, “InnoDB Data-at-Rest Encryption”</a>.
        </p></li><li class="listitem"><p>
          To reset the current auto-increment value:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 AUTO_INCREMENT = 13;</code></pre><p>
          You cannot reset the counter to a value less than or equal to
          the value that is currently in use. For both
          <code class="literal">InnoDB</code> and <code class="literal">MyISAM</code>, if
          the value is less than or equal to the maximum value currently
          in the <code class="literal">AUTO_INCREMENT</code> column, the value is
          reset to the current maximum <code class="literal">AUTO_INCREMENT</code>
          column value plus one.
        </p></li><li class="listitem"><p>
          To change the default table character set:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 CHARACTER SET = utf8;</code></pre><p>
          See also <a class="xref" href="alter-table.html#alter-table-character-set" title="Changing the Character Set">Changing the Character Set</a>.
        </p></li><li class="listitem"><p>
          To add (or change) a table comment:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 COMMENT = 'New table comment';</code></pre></li><li class="listitem"><p>
          Use <code class="literal">ALTER TABLE</code> with the
          <code class="literal">TABLESPACE</code> option to move
          <code class="literal">InnoDB</code> tables between existing
          <a class="link" href="glossary.html#glos_general_tablespace" title="general tablespace">general
          tablespaces</a>,
          <a class="link" href="glossary.html#glos_file_per_table" title="file-per-table">file-per-table</a>
          tablespaces, and the
          <a class="link" href="glossary.html#glos_system_tablespace" title="system tablespace">system
          tablespace</a>. See
          <a class="xref" href="general-tablespaces.html#general-tablespaces-moving-non-partitioned-tables" title="Moving Tables Between Tablespaces Using ALTER TABLE">Moving Tables Between Tablespaces Using ALTER TABLE</a>.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>
              <code class="literal">ALTER TABLE ... TABLESPACE</code> operations
              always cause a full table rebuild, even if the
              <code class="literal">TABLESPACE</code> attribute has not changed
              from its previous value.
            </p></li><li class="listitem"><p>
              <code class="literal">ALTER TABLE ... TABLESPACE</code> syntax does
              not support moving a table from a temporary tablespace to
              a persistent tablespace.
            </p></li><li class="listitem"><p>
              The <code class="literal">DATA DIRECTORY</code> clause, which is
              supported with
              <a class="link" href="create-table.html" title="13.1.20 CREATE TABLE Syntax"><code class="literal">CREATE TABLE
              ... TABLESPACE</code></a>, is not supported with
              <code class="literal">ALTER TABLE ... TABLESPACE</code>, and is
              ignored if specified.
            </p></li><li class="listitem"><p>
              For more information about the capabilities and
              limitations of the <code class="literal">TABLESPACE</code> option,
              see <a class="link" href="create-table.html" title="13.1.20 CREATE TABLE Syntax"><code class="literal">CREATE TABLE</code></a>.
</p></li></ul>
</div>
</li><li class="listitem"><p>
          MySQL NDB Cluster 8.0 supports setting
          <code class="literal">NDB_TABLE</code> options for controlling a
          table's partition balance (fragment count type),
          read-from-any-replica capability, full replication, or any
          combination of these, as part of the table comment for an
          <code class="literal">ALTER TABLE</code> statement in the same manner as
          for <a class="link" href="create-table.html" title="13.1.20 CREATE TABLE Syntax"><code class="literal">CREATE TABLE</code></a>, as shown in
          this example:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 COMMENT = "NDB_TABLE=READ_BACKUP=0,PARTITION_BALANCE=FOR_RA_BY_NODE";</code></pre><p>
          Bear in mind that <code class="literal">ALTER TABLE ... COMMENT
          ...</code> discards any existing comment for the table. See
          <a class="xref" href="create-table.html#create-table-comment-ndb-table-options" title="Setting NDB_TABLE options">Setting NDB_TABLE options</a>, for
          additional information and examples.
</p></li></ul>
</div>
<p>
      To verify that the table options were changed as intended, use
      <a class="link" href="show-create-table.html" title="13.7.6.10 SHOW CREATE TABLE Syntax"><code class="literal">SHOW CREATE TABLE</code></a>, or query the
      <a class="link" href="tables-table.html" title="25.30 The INFORMATION_SCHEMA TABLES Table"><code class="literal">INFORMATION_SCHEMA.TABLES</code></a> table.
</p>
<h4><a name="alter-table-performance"></a>Performance and Space Requirements</h4>
<p>
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> operations are
      processed using one of the following algorithms:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          <code class="literal">COPY</code>: Operations are performed on a copy of
          the original table, and table data is copied from the original
          table to the new table row by row. Concurrent DML is not
          permitted.
        </p></li><li class="listitem"><p>
          <code class="literal">INPLACE</code>: Operations avoid copying table
          data but may rebuild the table in place. An exclusive metadata
          lock on the table may be taken briefly during preparation and
          execution phases of the operation. Typically, concurrent DML
          is supported.
        </p></li><li class="listitem"><p>
          <code class="literal">INSTANT</code>: Operations only modify metadata in
          the data dictionary. No exclusive metadata locks are taken on
          the table during preparation and execution, and table data is
          unaffected, making operations instantaneous. Concurrent DML is
          permitted. (Introduced in MySQL 8.0.12)
</p></li></ul>
</div>
<p>
      The <code class="literal">ALGORITHM</code> clause is optional. If the
      <code class="literal">ALGORITHM</code> clause is omitted, MySQL uses
      <code class="literal">ALGORITHM=INSTANT</code> for storage engines and
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> clauses that support
      it. Otherwise, <code class="literal">ALGORITHM=INPLACE</code> is used. If
      <code class="literal">ALGORITHM=INPLACE</code> is not supported,
      <code class="literal">ALGORITHM=COPY</code> is used.
    </p><p>
      Specifying an <code class="literal">ALGORITHM</code> clause requires the
      operation to use the specified algorithm for clauses and storage
      engines that support it, or fail with an error otherwise.
      Specifying <code class="literal">ALGORITHM=DEFAULT</code> is the same as
      omitting the <code class="literal">ALGORITHM</code> clause.
    </p><p>
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> operations that use the
      <code class="literal">COPY</code> algorithm wait for other operations that
      are modifying the table to complete. After alterations are applied
      to the table copy, data is copied over, the original table is
      deleted, and the table copy is renamed to the name of the original
      table. While the <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>
      operation executes, the original table is readable by other
      sessions (with the exception noted shortly). Updates and writes to
      the table started after the <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER
      TABLE</code></a> operation begins are stalled until the new table
      is ready, then are automatically redirected to the new table. The
      temporary copy of the table is created in the database directory
      of the original table unless it is a <code class="literal">RENAME TO</code>
      operation that moves the table to a database that resides in a
      different directory.
    </p><p>
      The exception referred to earlier is that
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> blocks reads (not just
      writes) at the point where it is ready to clear outdated table
      structures from the table and table definition caches. At this
      point, it must acquire an exclusive lock. To do so, it waits for
      current readers to finish, and blocks new reads and writes.
    </p><p>
      An <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> operation that uses
      the <code class="literal">COPY</code> algorithm prevents concurrent DML
      operations. Concurrent queries are still allowed. That is, a
      table-copying operation always includes at least the concurrency
      restrictions of <code class="literal">LOCK=SHARED</code> (allow queries but
      not DML). You can further restrict concurrency for operations that
      support the <code class="literal">LOCK</code> clause by specifying
      <code class="literal">LOCK=EXCLUSIVE</code>, which prevents DML and queries.
      For more information, see
      <a class="xref" href="alter-table.html#alter-table-concurrency" title="Concurrency Control">Concurrency Control</a>.
    </p><p>
      To force use of the <code class="literal">COPY</code> algorithm for an
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> operation that would
      otherwise not use it, specify <code class="literal">ALGORITHM=COPY</code> or
      enable the <a class="link" href="server-system-variables.html#sysvar_old_alter_table"><code class="literal">old_alter_table</code></a> system
      variable. If there is a conflict between the
      <code class="literal">old_alter_table</code> setting and an
      <code class="literal">ALGORITHM</code> clause with a value other than
      <code class="literal">DEFAULT</code>, the <code class="literal">ALGORITHM</code>
      clause takes precedence.
    </p><p>
      For <code class="literal">InnoDB</code> tables, an
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> operation that uses the
      <code class="literal">COPY</code> algorithm on a table that resides in a
      <a class="link" href="glossary.html#glos_shared_tablespace" title="shared tablespace">shared tablespace</a>
      can increase the amount of space used by the tablespace. Such
      operations require as much additional space as the data in the
      table plus indexes. For a table residing in a shared tablespace,
      the additional space used during the operation is not released
      back to the operating system as it is for a table that resides in
      a <a class="link" href="glossary.html#glos_file_per_table" title="file-per-table">file-per-table</a>
      tablespace.
    </p><p>
      For information about space requirements for online DDL
      operations, see
      <a class="xref" href="innodb-online-ddl-space-requirements.html" title="15.12.3 Online DDL Space Requirements">Section 15.12.3, “Online DDL Space Requirements”</a>.
    </p><p>
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> operations that support
      the <code class="literal">INPLACE</code> algorithm include:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          <code class="literal">ALTER TABLE</code> operations supported by the
          <code class="literal">InnoDB</code>
          <a class="link" href="glossary.html#glos_online_ddl" title="online DDL">online DDL</a> feature. See
          <a class="xref" href="innodb-online-ddl-operations.html" title="15.12.1 Online DDL Operations">Section 15.12.1, “Online DDL Operations”</a>.
        </p></li><li class="listitem"><p>
          Renaming a table. MySQL renames files that correspond to the
          table <em class="replaceable"><code>tbl_name</code></em> without making a
          copy. (You can also use the <a class="link" href="rename-table.html" title="13.1.36 RENAME TABLE Syntax"><code class="literal">RENAME
          TABLE</code></a> statement to rename tables. See
          <a class="xref" href="rename-table.html" title="13.1.36 RENAME TABLE Syntax">Section 13.1.36, “RENAME TABLE Syntax”</a>.) Privileges granted
          specifically for the renamed table are not migrated to the new
          name. They must be changed manually.
        </p></li><li class="listitem"><p>
          Operations that only modify table metadata. These operations
          are immediate because the server does not touch table
          contents. Metadata-only operations include:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>
              Renaming a column.
            </p></li><li class="listitem"><p>
              Changing the default value of a column (except for
              <a class="link" href="mysql-cluster.html" title="Chapter 22 MySQL NDB Cluster 8.0"><code class="literal">NDB</code></a> tables).
            </p></li><li class="listitem"><p>
              Modifying the definition of an
              <a class="link" href="enum.html" title="11.4.4 The ENUM Type"><code class="literal">ENUM</code></a> or
              <a class="link" href="set.html" title="11.4.5 The SET Type"><code class="literal">SET</code></a> column by adding new
              enumeration or set members to the <span class="emphasis"><em>end</em></span>
              of the list of valid member values, as long as the storage
              size of the data type does not change. For example, adding
              a member to a <a class="link" href="set.html" title="11.4.5 The SET Type"><code class="literal">SET</code></a> column
              that has 8 members changes the required storage per value
              from 1 byte to 2 bytes; this requires a table copy. Adding
              members in the middle of the list causes renumbering of
              existing members, which requires a table copy.
            </p></li><li class="listitem"><p>
              Changing the definition of a spatial column to remove the
              <code class="literal">SRID</code> attribute. (Adding or changing an
              <code class="literal">SRID</code> attribute does require a rebuild
              and cannot be done in place because the server must verify
              that all values have the specified SRID value.)
            </p></li><li class="listitem"><p>
              As of MySQL 8.0.14, changing a column character set, when
              these conditions apply:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: square; "><li class="listitem"><p>
                  The column data type is
                  <a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">CHAR</code></a>,
                  <a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">VARCHAR</code></a>, a
                  <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">TEXT</code></a> type, or
                  <a class="link" href="enum.html" title="11.4.4 The ENUM Type"><code class="literal">ENUM</code></a>.
                </p></li><li class="listitem"><p>
                  The character set change is from
                  <code class="literal">utf8mb3</code> to
                  <code class="literal">utf8mb4</code>, or any character set to
                  <code class="literal">binary</code>.
                </p></li><li class="listitem"><p>
                  There is no index on the column.
</p></li></ul>
</div>
</li><li class="listitem"><p>
              As of MySQL 8.0.14, changing a generated column, when
              these conditions apply:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: square; "><li class="listitem"><p>
                  For <code class="literal">InnoDB</code> tables, statements that
                  modify generated stored columns but do not change
                  their type, expression, or nullability.
                </p></li><li class="listitem"><p>
                  For non-<code class="literal">InnoDB</code> tables, statements
                  that modify generated stored or virtual columns but do
                  not change their type, expression, or nullability.
</p></li></ul>
</div>
<p>
              An example of such a change is a change to the column
              comment.
</p></li></ul>
</div>
</li><li class="listitem"><p>
          Renaming an index.
        </p></li><li class="listitem"><p>
          Adding or dropping a secondary index, for
          <a class="link" href="innodb-storage-engine.html" title="Chapter 15 The InnoDB Storage Engine"><code class="literal">InnoDB</code></a> and
          <a class="link" href="mysql-cluster.html" title="Chapter 22 MySQL NDB Cluster 8.0"><code class="literal">NDB</code></a> tables. See
          <a class="xref" href="innodb-online-ddl-operations.html" title="15.12.1 Online DDL Operations">Section 15.12.1, “Online DDL Operations”</a>.
        </p></li><li class="listitem"><p>
          For <a class="link" href="mysql-cluster.html" title="Chapter 22 MySQL NDB Cluster 8.0"><code class="literal">NDB</code></a> tables, operations that
          add and drop indexes on variable-width columns. These
          operations occur online, without table copying and without
          blocking concurrent DML actions for most of their duration.
          See <a class="xref" href="mysql-cluster-online-operations.html" title="22.5.14 Online Operations with ALTER TABLE in NDB Cluster">Section 22.5.14, “Online Operations with ALTER TABLE in NDB Cluster”</a>.
        </p></li><li class="listitem"><p>
          Modifying index visibility with an <code class="literal">ALTER
          INDEX</code> operation.
        </p></li><li class="listitem"><p>
          Column modifications of tables containing generated columns
          that depend on columns with a <code class="literal">DEFAULT</code> value
          if the modified columns are not involved in the generated
          column expressions. For example, changing the
          <code class="literal">NULL</code> property of a separate column can be
          done in place without a table rebuild.
</p></li></ul>
</div>
<p>
      <code class="literal">ALTER TABLE</code> operations that support the
      <code class="literal">INSTANT</code> algorithm include:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          Adding a column. This feature is referred to as <span class="quote">“<span class="quote">Instant
          <code class="literal">ADD COLUMN</code></span>”</span>. Limitations apply. See
          <a class="xref" href="innodb-online-ddl-operations.html" title="15.12.1 Online DDL Operations">Section 15.12.1, “Online DDL Operations”</a>.
        </p></li><li class="listitem"><p>
          Adding or dropping a virtual column.
        </p></li><li class="listitem"><p>
          Adding or dropping a column default value.
        </p></li><li class="listitem"><p>
          Modifying the definition of an
          <a class="link" href="enum.html" title="11.4.4 The ENUM Type"><code class="literal">ENUM</code></a> or
          <a class="link" href="set.html" title="11.4.5 The SET Type"><code class="literal">SET</code></a> column. The same
          restrictions apply as described above for
          <code class="literal">ALGORITHM=INSTANT</code>.
        </p></li><li class="listitem"><p>
          Changing the index type.
        </p></li><li class="listitem"><p>
          Renaming a table. The same restrictions apply as described
          above for <code class="literal">ALGORITHM=INSTANT</code>.
</p></li></ul>
</div>
<p>
      For more information about operations that support
      <code class="literal">ALGORITHM=INSTANT</code>, see
      <a class="xref" href="innodb-online-ddl-operations.html" title="15.12.1 Online DDL Operations">Section 15.12.1, “Online DDL Operations”</a>.
    </p><p>
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> upgrades MySQL 5.5
      temporal columns to 5.6 format for <code class="literal">ADD COLUMN</code>,
      <code class="literal">CHANGE COLUMN</code>, <code class="literal">MODIFY
      COLUMN</code>, <code class="literal">ADD INDEX</code>, and
      <code class="literal">FORCE</code> operations. This conversion cannot be
      done using the <code class="literal">INPLACE</code> algorithm because the
      table must be rebuilt, so specifying
      <code class="literal">ALGORITHM=INPLACE</code> in these cases results in an
      error. Specify <code class="literal">ALGORITHM=COPY</code> if necessary.
    </p><p>
      If an <code class="literal">ALTER TABLE</code> operation on a multicolumn
      index used to partition a table by <code class="literal">KEY</code> changes
      the order of the columns, it can only be performed using
      <code class="literal">ALGORITHM=COPY</code>.
    </p><p>
      The <code class="literal">WITHOUT VALIDATION</code> and <code class="literal">WITH
      VALIDATION</code> clauses affect whether
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> performs an in-place
      operation for
      <a class="link" href="glossary.html#glos_virtual_generated_column" title="virtual generated column">virtual generated
      column</a> modifications. See
      <a class="xref" href="alter-table-generated-columns.html" title="13.1.9.2 ALTER TABLE and Generated Columns">Section 13.1.9.2, “ALTER TABLE and Generated Columns”</a>.
    </p><p>
      NDB Cluster 8.0 supports online operations using the same
      <code class="literal">ALGORITHM=INPLACE</code> syntax used with the standard
      MySQL Server. See
      <a class="xref" href="mysql-cluster-online-operations.html" title="22.5.14 Online Operations with ALTER TABLE in NDB Cluster">Section 22.5.14, “Online Operations with ALTER TABLE in NDB Cluster”</a>, for more
      information.
    </p><p>
      <code class="literal">ALTER TABLE</code> with <code class="literal">DISCARD ... PARTITION
      ... TABLESPACE</code> or <code class="literal">IMPORT ... PARTITION ...
      TABLESPACE</code> does not create any temporary tables or
      temporary partition files.
    </p><p>
      <code class="literal">ALTER TABLE</code> with <code class="literal">ADD
      PARTITION</code>, <code class="literal">DROP PARTITION</code>,
      <code class="literal">COALESCE PARTITION</code>, <code class="literal">REBUILD
      PARTITION</code>, or <code class="literal">REORGANIZE PARTITION</code>
      does not create temporary tables (except when used with
      <a class="link" href="mysql-cluster.html" title="Chapter 22 MySQL NDB Cluster 8.0"><code class="literal">NDB</code></a> tables); however, these
      operations can and do create temporary partition files.
    </p><p>
      <code class="literal">ADD</code> or <code class="literal">DROP</code> operations for
      <code class="literal">RANGE</code> or <code class="literal">LIST</code> partitions are
      immediate operations or nearly so. <code class="literal">ADD</code> or
      <code class="literal">COALESCE</code> operations for <code class="literal">HASH</code>
      or <code class="literal">KEY</code> partitions copy data between all
      partitions, unless <code class="literal">LINEAR HASH</code> or
      <code class="literal">LINEAR KEY</code> was used; this is effectively the
      same as creating a new table, although the <code class="literal">ADD</code>
      or <code class="literal">COALESCE</code> operation is performed partition by
      partition. <code class="literal">REORGANIZE</code> operations copy only
      changed partitions and do not touch unchanged ones.
    </p><p>
      For <code class="literal">MyISAM</code> tables, you can speed up index
      re-creation (the slowest part of the alteration process) by
      setting the
      <a class="link" href="server-system-variables.html#sysvar_myisam_sort_buffer_size"><code class="literal">myisam_sort_buffer_size</code></a> system
      variable to a high value.
</p>
<h4><a name="alter-table-concurrency"></a>Concurrency Control</h4>
<p>
      For <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> operations that
      support it, you can use the <code class="literal">LOCK</code> clause to
      control the level of concurrent reads and writes on a table while
      it is being altered. Specifying a non-default value for this
      clause enables you to require a certain amount of concurrent
      access or exclusivity during the alter operation, and halts the
      operation if the requested degree of locking is not available.
    </p><p>
      Only <code class="literal">LOCK = DEFAULT</code> is permitted for operations
      that use <code class="literal">ALGORITHM=INSTANT</code>. The other
      <code class="literal">LOCK</code> clause parameters are not applicable.
    </p><p>
      The parameters for the <code class="literal">LOCK</code> clause are:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
</p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">LOCK = DEFAULT</code></pre><p>

          Maximum level of concurrency for the given
          <code class="literal">ALGORITHM</code> clause (if any) and
          <code class="literal">ALTER TABLE</code> operation: Permit concurrent
          reads and writes if supported. If not, permit concurrent reads
          if supported. If not, enforce exclusive access.
        </p></li><li class="listitem"><p>
</p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">LOCK = NONE</code></pre><p>

          If supported, permit concurrent reads and writes. Otherwise,
          an error occurs.
        </p></li><li class="listitem"><p>
</p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">LOCK = SHARED</code></pre><p>

          If supported, permit concurrent reads but block writes. Writes
          are blocked even if concurrent writes are supported by the
          storage engine for the given <code class="literal">ALGORITHM</code>
          clause (if any) and <code class="literal">ALTER TABLE</code> operation.
          If concurrent reads are not supported, an error occurs.
        </p></li><li class="listitem"><p>
</p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">LOCK = EXCLUSIVE</code></pre><p>

          Enforce exclusive access. This is done even if concurrent
          reads/writes are supported by the storage engine for the given
          <code class="literal">ALGORITHM</code> clause (if any) and
          <code class="literal">ALTER TABLE</code> operation.
</p></li></ul>
</div>
<h4><a name="alter-table-add-drop-column"></a>Adding and Dropping Columns</h4>
<p>
      Use <code class="literal">ADD</code> to add new columns to a table, and
      <code class="literal">DROP</code> to remove existing columns. <code class="literal">DROP
      <em class="replaceable"><code>col_name</code></em></code> is a MySQL extension
      to standard SQL.
    </p><p>
      To add a column at a specific position within a table row, use
      <code class="literal">FIRST</code> or <code class="literal">AFTER
      <em class="replaceable"><code>col_name</code></em></code>. The default is to
      add the column last.
    </p><p>
      If a table contains only one column, the column cannot be dropped.
      If what you intend is to remove the table, use the
      <a class="link" href="drop-table.html" title="13.1.32 DROP TABLE Syntax"><code class="literal">DROP TABLE</code></a> statement instead.
    </p><p>
      If columns are dropped from a table, the columns are also removed
      from any index of which they are a part. If all columns that make
      up an index are dropped, the index is dropped as well. If you use
      <code class="literal">CHANGE</code> or <code class="literal">MODIFY</code> to shorten
      a column for which an index exists on the column, and the
      resulting column length is less than the index length, MySQL
      shortens the index automatically.
    </p><p>
      For <code class="literal">ALTER TABLE ... ADD</code>, if the column has an
      expression default value that uses a nondeterministic function,
      the statement may produce a warning or error. For details, see
      <a class="xref" href="replication-gtids-restrictions.html" title="17.1.3.6 Restrictions on Replication with GTIDs">Section 17.1.3.6, “Restrictions on Replication with GTIDs”</a>.
</p>
<h4><a name="alter-table-redefine-column"></a>Renaming, Redefining, and Reordering Columns</h4>
<a class="indexterm" name="idm139663178793328"></a><a class="indexterm" name="idm139663178791840"></a><a class="indexterm" name="idm139663178790352"></a><a class="indexterm" name="idm139663178788864"></a><p>
      The <code class="literal">CHANGE</code>, <code class="literal">MODIFY</code>,
      <code class="literal">RENAME COLUMN</code>, and <code class="literal">ALTER</code>
      clauses enable the names and definitions of existing columns to be
      altered. They have these comparative characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          <code class="literal">CHANGE</code>:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>
              Can rename a column and change its definition, or both.
            </p></li><li class="listitem"><p>
              Has more capability than <code class="literal">MODIFY</code> or
              <code class="literal">RENAME COLUMN</code>, but at the expense of
              convenience for some operations. <code class="literal">CHANGE</code>
              requires naming the column twice if not renaming it, and
              requires respecifying the column definition if only
              renaming it.
            </p></li><li class="listitem"><p>
              With <code class="literal">FIRST</code> or <code class="literal">AFTER</code>,
              can reorder columns.
</p></li></ul>
</div>
</li><li class="listitem"><p>
          <code class="literal">MODIFY</code>:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>
              Can change a column definition but not its name.
            </p></li><li class="listitem"><p>
              More convenient than <code class="literal">CHANGE</code> to change a
              column definition without renaming it.
            </p></li><li class="listitem"><p>
              With <code class="literal">FIRST</code> or <code class="literal">AFTER</code>,
              can reorder columns.
</p></li></ul>
</div>
</li><li class="listitem"><p>
          <code class="literal">RENAME COLUMN</code>:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>
              Can change a column name but not its definition.
            </p></li><li class="listitem"><p>
              More convenient than <code class="literal">CHANGE</code> to rename a
              column without changing its definition.
</p></li></ul>
</div>
</li><li class="listitem"><p>
          <code class="literal">ALTER</code>: Used only to change a column default
          value.
</p></li></ul>
</div>
<a class="indexterm" name="idm139663178762960"></a><a class="indexterm" name="idm139663178761888"></a><p>
      <code class="literal">CHANGE</code> is a MySQL extension to standard SQL.
      <code class="literal">MODIFY</code> and <code class="literal">RENAME COLUMN</code> are
      MySQL extensions for Oracle compatibility.
    </p><p>
      To alter a column to change both its name and definition, use
      <code class="literal">CHANGE</code>, specifying the old and new names and
      the new definition. For example, to rename an <code class="literal">INT NOT
      NULL</code> column from <code class="literal">a</code> to
      <code class="literal">b</code> and change its definition to use the
      <code class="literal">BIGINT</code> data type while retaining the
      <code class="literal">NOT NULL</code> attribute, do this:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 CHANGE a b BIGINT NOT NULL;</code></pre><p>
      To change a column definition but not its name, use
      <code class="literal">CHANGE</code> or <code class="literal">MODIFY</code>. With
      <code class="literal">CHANGE</code>, the syntax requires two column names,
      so you must specify the same name twice to leave the name
      unchanged. For example, to change the definition of column
      <code class="literal">b</code>, do this:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 CHANGE b b INT NOT NULL;</code></pre><p>
      <code class="literal">MODIFY</code> is more convenient to change the
      definition without changing the name because it requires the
      column name only once:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 MODIFY b INT NOT NULL;</code></pre><p>
      To change a column name but not its definition, use
      <code class="literal">CHANGE</code> or <code class="literal">RENAME COLUMN</code>.
      With <code class="literal">CHANGE</code>, the syntax requires a column
      definition, so to leave the definition unchanged, you must
      respecify the definition the column currently has. For example, to
      rename an <code class="literal">INT NOT NULL</code> column from
      <code class="literal">b</code> to <code class="literal">a</code>, do this:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 CHANGE b a INT NOT NULL;</code></pre><p>
      <code class="literal">RENAME COLUMN</code> is more convenient to change the
      name without changing the definition because it requires only the
      old and new names:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 RENAME COLUMN b TO a;</code></pre><p>
      In general, you cannot rename a column to a name that already
      exists in the table. However, this is sometimes not the case, such
      as when you swap names or move them through a cycle. If a table
      has columns named <code class="literal">a</code>, <code class="literal">b</code>, and
      <code class="literal">c</code>, these are valid operations:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">-- swap a and b
ALTER TABLE t1 RENAME COLUMN a TO b,
               RENAME COLUMN b TO a;
-- "rotate" a, b, c through a cycle
ALTER TABLE t1 RENAME COLUMN a TO b,
               RENAME COLUMN b TO c,
               RENAME COLUMN c TO a;</code></pre><p>
      For column definition changes using <code class="literal">CHANGE</code> or
      <code class="literal">MODIFY</code>, the definition must include the data
      type and all attributes that should apply to the new column, other
      than index attributes such as <code class="literal">PRIMARY KEY</code> or
      <code class="literal">UNIQUE</code>. Attributes present in the original
      definition but not specified for the new definition are not
      carried forward. Suppose that a column <code class="literal">col1</code> is
      defined as <code class="literal">INT UNSIGNED DEFAULT 1 COMMENT 'my
      column'</code> and you modify the column as follows, intending
      to change only <code class="literal">INT</code> to
      <code class="literal">BIGINT</code>:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 MODIFY col1 BIGINT;</code></pre><p>
      That statement changes the data type from <code class="literal">INT</code>
      to <code class="literal">BIGINT</code>, but it also drops the
      <code class="literal">UNSIGNED</code>, <code class="literal">DEFAULT</code>, and
      <code class="literal">COMMENT</code> attributes. To retain them, the
      statement must include them explicitly:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE t1 MODIFY col1 BIGINT UNSIGNED DEFAULT 1 COMMENT 'my column';</code></pre><p>
      For data type changes using <code class="literal">CHANGE</code> or
      <code class="literal">MODIFY</code>, MySQL tries to convert existing column
      values to the new type as well as possible.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Warning
</div>
<p>
        This conversion may result in alteration of data. For example,
        if you shorten a string column, values may be truncated. To
        prevent the operation from succeeding if conversions to the new
        data type would result in loss of data, enable strict SQL mode
        before using <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> (see
        <a class="xref" href="sql-mode.html" title="5.1.11 Server SQL Modes">Section 5.1.11, “Server SQL Modes”</a>).
</p>
</div>
<p>
      If you use <code class="literal">CHANGE</code> or <code class="literal">MODIFY</code>
      to shorten a column for which an index exists on the column, and
      the resulting column length is less than the index length, MySQL
      shortens the index automatically.
    </p><p>
      For columns renamed by <code class="literal">CHANGE</code> or
      <code class="literal">RENAME COLUMN</code>, MySQL automatically renames
      these references to the renamed column:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          Indexes that refer to the old column, including invisible
          indexes and disabled <code class="literal">MyISAM</code> indexes.
        </p></li><li class="listitem"><p>
          Foreign keys that refer to the old column.
</p></li></ul>
</div>
<p>
      For columns renamed by <code class="literal">CHANGE</code> or
      <code class="literal">RENAME COLUMN</code>, MySQL does not automatically
      rename these references to the renamed column:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          Generated column and partition expressions that refer to the
          renamed column. You must use <code class="literal">CHANGE</code> to
          redefine such expressions in the same
          <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> statement as the
          one that renames the column.
        </p></li><li class="listitem"><p>
          Views and stored programs that refer to the renamed column.
          You must manually alter the definition of these objects to
          refer to the new column name.
</p></li></ul>
</div>
<p>
      To reorder columns within a table, use <code class="literal">FIRST</code>
      and <code class="literal">AFTER</code> in <code class="literal">CHANGE</code> or
      <code class="literal">MODIFY</code> operations.
    </p><a class="indexterm" name="idm139663178699648"></a><p>
      <code class="literal">ALTER ... SET DEFAULT</code> or <code class="literal">ALTER ...
      DROP DEFAULT</code> specify a new default value for a column or
      remove the old default value, respectively. If the old default is
      removed and the column can be <code class="literal">NULL</code>, the new
      default is <code class="literal">NULL</code>. If the column cannot be
      <code class="literal">NULL</code>, MySQL assigns a default value as
      described in <a class="xref" href="data-type-defaults.html" title="11.7 Data Type Default Values">Section 11.7, “Data Type Default Values”</a>.
</p>
<h4><a name="alter-table-index"></a>Primary Keys and Indexes</h4>
<a class="indexterm" name="idm139663178692512"></a><a class="indexterm" name="idm139663178691472"></a><a class="indexterm" name="idm139663178689984"></a><p>
      <code class="literal">DROP PRIMARY KEY</code> drops the
      <a class="link" href="glossary.html#glos_primary_key" title="primary key">primary key</a>. If there is
      no primary key, an error occurs. For information about the
      performance characteristics of primary keys, especially for
      <code class="literal">InnoDB</code> tables, see
      <a class="xref" href="primary-key-optimization.html" title="8.3.2 Primary Key Optimization">Section 8.3.2, “Primary Key Optimization”</a>.
    </p><a class="indexterm" name="idm139663178684832"></a><a class="indexterm" name="idm139663178683760"></a><p>
      If you add a <code class="literal">UNIQUE INDEX</code> or <code class="literal">PRIMARY
      KEY</code> to a table, MySQL stores it before any nonunique
      index to permit detection of duplicate keys as early as possible.
    </p><a class="indexterm" name="idm139663178680752"></a><a class="indexterm" name="idm139663178679680"></a><a class="indexterm" name="idm139663178678192"></a><p>
      <a class="link" href="drop-index.html" title="13.1.27 DROP INDEX Syntax"><code class="literal">DROP INDEX</code></a> removes an index. This
      is a MySQL extension to standard SQL. See
      <a class="xref" href="drop-index.html" title="13.1.27 DROP INDEX Syntax">Section 13.1.27, “DROP INDEX Syntax”</a>. To determine index names, use
      <code class="literal">SHOW INDEX FROM
      <em class="replaceable"><code>tbl_name</code></em></code>.
    </p><p>
      Some storage engines permit you to specify an index type when
      creating an index. The syntax for the
      <em class="replaceable"><code>index_type</code></em> specifier is <code class="literal">USING
      <em class="replaceable"><code>type_name</code></em></code>. For details about
      <code class="literal">USING</code>, see <a class="xref" href="create-index.html" title="13.1.15 CREATE INDEX Syntax">Section 13.1.15, “CREATE INDEX Syntax”</a>. The
      preferred position is after the column list. Support for use of
      the option before the column list will be removed in a future
      MySQL release.
    </p><p>
      <em class="replaceable"><code>index_option</code></em> values specify additional
      options for an index. <code class="literal">USING</code> is one such option.
      For details about permissible
      <em class="replaceable"><code>index_option</code></em> values, see
      <a class="xref" href="create-index.html" title="13.1.15 CREATE INDEX Syntax">Section 13.1.15, “CREATE INDEX Syntax”</a>.
    </p><p>
      <code class="literal">RENAME INDEX <em class="replaceable"><code>old_index_name</code></em> TO
      <em class="replaceable"><code>new_index_name</code></em></code> renames an
      index. This is a MySQL extension to standard SQL. The content of
      the table remains unchanged.
      <em class="replaceable"><code>old_index_name</code></em> must be the name of an
      existing index in the table that is not dropped by the same
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> statement.
      <em class="replaceable"><code>new_index_name</code></em> is the new index name,
      which cannot duplicate the name of an index in the resulting table
      after changes have been applied. Neither index name can be
      <code class="literal">PRIMARY</code>.
    </p><a class="indexterm" name="idm139663178662000"></a><a class="indexterm" name="idm139663178660928"></a><a class="indexterm" name="idm139663178659440"></a><p>
      If you use <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> on a
      <code class="literal">MyISAM</code> table, all nonunique indexes are created
      in a separate batch (as for <a class="link" href="repair-table.html" title="13.7.3.5 REPAIR TABLE Syntax"><code class="literal">REPAIR
      TABLE</code></a>). This should make <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER
      TABLE</code></a> much faster when you have many indexes.
    </p><p>
      For <code class="literal">MyISAM</code> tables, key updating can be
      controlled explicitly. Use <code class="literal">ALTER TABLE ... DISABLE
      KEYS</code> to tell MySQL to stop updating nonunique indexes.
      Then use <code class="literal">ALTER TABLE ... ENABLE KEYS</code> to
      re-create missing indexes. <code class="literal">MyISAM</code> does this
      with a special algorithm that is much faster than inserting keys
      one by one, so disabling keys before performing bulk insert
      operations should give a considerable speedup. Using
      <code class="literal">ALTER TABLE ... DISABLE KEYS</code> requires the
      <a class="link" href="privileges-provided.html#priv_index"><code class="literal">INDEX</code></a> privilege in addition to the
      privileges mentioned earlier.
    </p><p>
      While the nonunique indexes are disabled, they are ignored for
      statements such as <a class="link" href="select.html" title="13.2.10 SELECT Syntax"><code class="literal">SELECT</code></a> and
      <a class="link" href="explain.html" title="13.8.2 EXPLAIN Syntax"><code class="literal">EXPLAIN</code></a> that otherwise would use
      them.
    </p><p>
      After an <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> statement, it
      may be necessary to run <a class="link" href="analyze-table.html" title="13.7.3.1 ANALYZE TABLE Syntax"><code class="literal">ANALYZE
      TABLE</code></a> to update index cardinality information. See
      <a class="xref" href="show-index.html" title="13.7.6.22 SHOW INDEX Syntax">Section 13.7.6.22, “SHOW INDEX Syntax”</a>.
    </p><a class="indexterm" name="idm139663178640768"></a><p>
      The <code class="literal">ALTER INDEX</code> operation permits an index to
      be made visible or invisible. An invisible index is not used by
      the optimizer. Modification of index visibility applies to indexes
      other than primary keys (either explicit or implicit). This
      feature is storage engine neutral (supported for any engine). For
      more information, see <a class="xref" href="invisible-indexes.html" title="8.3.12 Invisible Indexes">Section 8.3.12, “Invisible Indexes”</a>.
</p>
<h4><a name="alter-table-foreign-key"></a>Foreign Keys and Other Constraints</h4>
<a class="indexterm" name="idm139663178636384"></a><a class="indexterm" name="idm139663178635344"></a><p>
      The <code class="literal">FOREIGN KEY</code> and
      <code class="literal">REFERENCES</code> clauses are supported by the
      <code class="literal">InnoDB</code> and <code class="literal">NDB</code> storage
      engines, which implement <code class="literal">ADD [CONSTRAINT
      [<em class="replaceable"><code>symbol</code></em>]] FOREIGN KEY
      [<em class="replaceable"><code>index_name</code></em>] (...) REFERENCES ...
      (...)</code>. See
      <a class="xref" href="innodb-foreign-key-constraints.html" title="15.6.1.5 InnoDB and FOREIGN KEY Constraints">Section 15.6.1.5, “InnoDB and FOREIGN KEY Constraints”</a>. For other
      storage engines, the clauses are parsed but ignored.
    </p><p>
      For <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>, unlike
      <a class="link" href="create-table.html" title="13.1.20 CREATE TABLE Syntax"><code class="literal">CREATE TABLE</code></a>, <code class="literal">ADD FOREIGN
      KEY</code> ignores <em class="replaceable"><code>index_name</code></em> if
      given and uses an automatically generated foreign key name. As a
      workaround, include the <code class="literal">CONSTRAINT</code> clause to
      specify the foreign key name:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ADD CONSTRAINT <em class="replaceable">name</em> FOREIGN KEY (....) ...</code></pre>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Important
</div>
<p>
        MySQL silently ignores inline <code class="literal">REFERENCES</code>
        specifications, where the references are defined as part of the
        column specification. MySQL accepts only
        <code class="literal">REFERENCES</code> clauses defined as part of a
        separate <code class="literal">FOREIGN KEY</code> specification.
</p>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
        Partitioned <code class="literal">InnoDB</code> tables do not support
        foreign keys. This restriction does not apply to
        <code class="literal">NDB</code> tables, including those explicitly
        partitioned by <code class="literal">[LINEAR] KEY</code>. For more
        information, see
        <a class="xref" href="partitioning-limitations-storage-engines.html" title="23.6.2 Partitioning Limitations Relating to Storage Engines">Section 23.6.2, “Partitioning Limitations Relating to Storage Engines”</a>.
</p>
</div>
<a class="indexterm" name="idm139663178615296"></a><a class="indexterm" name="idm139663178614224"></a><a class="indexterm" name="idm139663178612736"></a><p>
      MySQL Server and NDB Cluster both support the use of
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> to drop foreign keys:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE <em class="replaceable">tbl_name</em> DROP FOREIGN KEY <em class="replaceable">fk_symbol</em>;</code></pre><p>
      Adding and dropping a foreign key in the same
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a> statement is supported
      for <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE ...
      ALGORITHM=INPLACE</code></a> but not for
      <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE ...
      ALGORITHM=COPY</code></a>.
    </p><p>
      The server prohibits changes to foreign key columns that have the
      potential to cause loss of referential integrity. A workaround is
      to use <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE
      ... DROP FOREIGN KEY</code></a> before changing the column
      definition and <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER
      TABLE ... ADD FOREIGN KEY</code></a> afterward. Examples of
      prohibited changes include:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          Changes to the data type of foreign key columns that may be
          unsafe. For example, changing
          <a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">VARCHAR(20)</code></a> to
          <a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">VARCHAR(30)</code></a> is permitted, but
          changing it to <a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">VARCHAR(1024)</code></a> is
          not because that alters the number of length bytes required to
          store individual values.
        </p></li><li class="listitem"><p>
          Changing a <code class="literal">NULL</code> column to <code class="literal">NOT
          NULL</code> in non-strict mode is prohibited to prevent
          converting <code class="literal">NULL</code> values to default
          non-<code class="literal">NULL</code> values, for which there are no
          corresponding values in the referenced table. The operation is
          permitted in strict mode, but an error is returned if any such
          conversion is required.
</p></li></ul>
</div>
<p>
      <code class="literal">ALTER TABLE <em class="replaceable"><code>tbl_name</code></em> RENAME
      <em class="replaceable"><code>new_tbl_name</code></em></code> changes
      internally generated foreign key constraint names and user-defined
      foreign key constraint names that begin with the string
      <span class="quote">“<span class="quote"><em class="replaceable"><code>tbl_name</code></em>_ibfk_</span>”</span> to
      reflect the new table name. <code class="literal">InnoDB</code> interprets
      foreign key constraint names that begin with the string
      <span class="quote">“<span class="quote"><em class="replaceable"><code>tbl_name</code></em>_ibfk_</span>”</span> as
      internally generated names.
    </p><a class="indexterm" name="idm139663178587104"></a><p>
      Prior to MySQL 8.0.16, <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>
      permits only the following limited version of
      <code class="literal">CHECK</code> constraint-adding syntax, which is parsed
      and ignored:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ADD CHECK (<em class="replaceable">expr</em>)</code></pre><p>
      As of MySQL 8.0.16, <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>
      permits <code class="literal">CHECK</code> constraints for existing tables
      to be added, dropped, or altered:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          Add a new constraint:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">ALTER TABLE <em class="replaceable">tbl_name</em>
    ADD CONSTRAINT [<em class="replaceable">symbol</em>] CHECK (<em class="replaceable">expr</em>) [[NOT] ENFORCED];</code></pre><p>
          The meaning of constraint syntax elements is the same as for
          <a class="link" href="create-table.html" title="13.1.20 CREATE TABLE Syntax"><code class="literal">CREATE TABLE</code></a>. See
          <a class="xref" href="create-table-check-constraints.html" title="13.1.20.7 CHECK Constraints">Section 13.1.20.7, “CHECK Constraints”</a>.
        </p></li><li class="listitem"><p>
          Drop an existing constraint named
          <em class="replaceable"><code>symbol</code></em>:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">ALTER TABLE <em class="replaceable">tbl_name</em>
    DROP CHECK <em class="replaceable">symbol</em>;</code></pre></li><li class="listitem"><p>
          Alter whether an existing constraint named
          <em class="replaceable"><code>symbol</code></em> is enforced:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">ALTER TABLE <em class="replaceable">tbl_name</em>
    ALTER CHECK <em class="replaceable">symbol</em> [NOT] ENFORCED;</code></pre></li></ul>
</div>
<p>
      The <code class="literal">DROP CHECK</code> and <code class="literal">ALTER
      CHECK</code> clauses are MySQL extensions to standard SQL.
    </p><p>
      If a table alteration causes a violation of an enforced
      <code class="literal">CHECK</code> constraint, an error occurs and the table
      is not modified. Examples of operations for which an error occurs:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          Attempts to add the <code class="literal">AUTO_INCREMENT</code>
          attribute to a column that is used in a
          <code class="literal">CHECK</code> constraint.
        </p></li><li class="listitem"><p>
          Attempts to add an enforced <code class="literal">CHECK</code>
          constraint or enforce a nonenforced <code class="literal">CHECK</code>
          constraint for which existing rows violate the constraint
          condition.
        </p></li><li class="listitem"><p>
          Attempts to modify, rename, or drop a column that is used in a
          <code class="literal">CHECK</code> constraint, unless that constraint is
          also dropped in the same statement. Exception: If a
          <code class="literal">CHECK</code> constraint refers only to a single
          column, dropping the column automatically drops the
          constraint.
</p></li></ul>
</div>
<p>
      <code class="literal">ALTER TABLE <em class="replaceable"><code>tbl_name</code></em> RENAME
      <em class="replaceable"><code>new_tbl_name</code></em></code> changes
      internally generated and user-defined <code class="literal">CHECK</code>
      constraint names that begin with the string
      <span class="quote">“<span class="quote"><em class="replaceable"><code>tbl_name</code></em>_chk_</span>”</span> to reflect
      the new table name. MySQL interprets <code class="literal">CHECK</code>
      constraint names that begin with the string
      <span class="quote">“<span class="quote"><em class="replaceable"><code>tbl_name</code></em>_chk_</span>”</span> as
      internally generated names.
</p>
<h4><a name="alter-table-character-set"></a>Changing the Character Set</h4>
<p>
      <a class="indexterm" name="idm139663178550176"></a>

      To change the table default character set and all character
      columns (<a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">CHAR</code></a>,
      <a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">VARCHAR</code></a>,
      <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">TEXT</code></a>) to a new character set, use a
      statement like this:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE <em class="replaceable">tbl_name</em> CONVERT TO CHARACTER SET <em class="replaceable">charset_name</em>;</code></pre><p>
      The statement also changes the collation of all character columns.
      If you specify no <code class="literal">COLLATE</code> clause to indicate
      which collation to use, the statement uses default collation for
      the character set. If this collation is inappropriate for the
      intended table use (for example, if it would change from a
      case-sensitive collation to a case-insensitive collation), specify
      a collation explicitly.
    </p><p>
      For a column that has a data type of
      <a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">VARCHAR</code></a> or one of the
      <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">TEXT</code></a> types, <code class="literal">CONVERT TO
      CHARACTER SET</code> changes the data type as necessary to
      ensure that the new column is long enough to store as many
      characters as the original column. For example, a
      <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">TEXT</code></a> column has two length bytes,
      which store the byte-length of values in the column, up to a
      maximum of 65,535. For a <code class="literal">latin1</code>
      <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">TEXT</code></a> column, each character
      requires a single byte, so the column can store up to 65,535
      characters. If the column is converted to <code class="literal">utf8</code>,
      each character might require up to three bytes, for a maximum
      possible length of 3 × 65,535 = 196,605 bytes. That length
      does not fit in a <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">TEXT</code></a> column's
      length bytes, so MySQL converts the data type to
      <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">MEDIUMTEXT</code></a>, which is the smallest
      string type for which the length bytes can record a value of
      196,605. Similarly, a <a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">VARCHAR</code></a>
      column might be converted to
      <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">MEDIUMTEXT</code></a>.
    </p><p>
      To avoid data type changes of the type just described, do not use
      <code class="literal">CONVERT TO CHARACTER SET</code>. Instead, use
      <code class="literal">MODIFY</code> to change individual columns. For
      example:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">ALTER TABLE t MODIFY latin1_text_col TEXT CHARACTER SET utf8;
ALTER TABLE t MODIFY latin1_varchar_col VARCHAR(<em class="replaceable">M</em>) CHARACTER SET utf8;</code></pre><p>
      If you specify <code class="literal">CONVERT TO CHARACTER SET binary</code>,
      the <a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">CHAR</code></a>,
      <a class="link" href="char.html" title="11.4.1 The CHAR and VARCHAR Types"><code class="literal">VARCHAR</code></a>, and
      <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">TEXT</code></a> columns are converted to their
      corresponding binary string types
      (<a class="link" href="binary-varbinary.html" title="11.4.2 The BINARY and VARBINARY Types"><code class="literal">BINARY</code></a>,
      <a class="link" href="binary-varbinary.html" title="11.4.2 The BINARY and VARBINARY Types"><code class="literal">VARBINARY</code></a>,
      <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">BLOB</code></a>). This means that the columns
      no longer will have a character set and a subsequent
      <code class="literal">CONVERT TO</code> operation will not apply to them.
    </p><p>
      If <em class="replaceable"><code>charset_name</code></em> is
      <code class="literal">DEFAULT</code> in a <code class="literal">CONVERT TO CHARACTER
      SET</code> operation, the character set named by the
      <a class="link" href="server-system-variables.html#sysvar_character_set_database"><code class="literal">character_set_database</code></a> system
      variable is used.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Warning
</div>
<p>
        The <code class="literal">CONVERT TO</code> operation converts column
        values between the original and named character sets. This is
        <span class="emphasis"><em>not</em></span> what you want if you have a column in
        one character set (like <code class="literal">latin1</code>) but the
        stored values actually use some other, incompatible character
        set (like <code class="literal">utf8</code>). In this case, you have to do
        the following for each such column:
      </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">ALTER TABLE t1 CHANGE c1 c1 BLOB;
ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8;</code></pre><p>
        The reason this works is that there is no conversion when you
        convert to or from <a class="link" href="blob.html" title="11.4.3 The BLOB and TEXT Types"><code class="literal">BLOB</code></a> columns.
</p>
</div>
<p>
      To change only the <span class="emphasis"><em>default</em></span> character set for
      a table, use this statement:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">ALTER TABLE <em class="replaceable">tbl_name</em> DEFAULT CHARACTER SET <em class="replaceable">charset_name</em>;</code></pre><p>
      The word <code class="literal">DEFAULT</code> is optional. The default
      character set is the character set that is used if you do not
      specify the character set for columns that you add to a table
      later (for example, with <code class="literal">ALTER TABLE ... ADD
      column</code>).
    </p><p>
      When the <a class="link" href="server-system-variables.html#sysvar_foreign_key_checks"><code class="literal">foreign_key_checks</code></a>
      system variable is enabled, which is the default setting,
      character set conversion is not permitted on tables that include a
      character string column used in a foreign key constraint. The
      workaround is to disable
      <a class="link" href="server-system-variables.html#sysvar_foreign_key_checks"><code class="literal">foreign_key_checks</code></a> before
      performing the character set conversion. You must perform the
      conversion on both tables involved in the foreign key constraint
      before re-enabling
      <a class="link" href="server-system-variables.html#sysvar_foreign_key_checks"><code class="literal">foreign_key_checks</code></a>. If you
      re-enable <a class="link" href="server-system-variables.html#sysvar_foreign_key_checks"><code class="literal">foreign_key_checks</code></a>
      after converting only one of the tables, an <code class="literal">ON DELETE
      CASCADE</code> or <code class="literal">ON UPDATE CASCADE</code>
      operation could corrupt data in the referencing table due to
      implicit conversion that occurs during these operations (Bug
      #45290, Bug #74816).
</p>
<h4><a name="alter-table-discard-import"></a>Discarding and Importing InnoDB Tablespaces</h4>
<a class="indexterm" name="idm139663178492096"></a><a class="indexterm" name="idm139663178491024"></a><p>
      An <code class="literal">InnoDB</code> table created in its own
      <a class="link" href="glossary.html#glos_file_per_table" title="file-per-table">file-per-table</a>
      tablespace can be discarded and imported using the
      <code class="literal">DISCARD TABLESPACE</code> and <code class="literal">IMPORT
      TABLESPACE</code> options. These options can be used to import
      a file-per-table tablespace from a backup or to copy a
      file-per-table tablespace from one database server to another. See
      <a class="xref" href="tablespace-copying.html" title="15.6.3.7 Copying Tablespaces to Another Instance">Section 15.6.3.7, “Copying Tablespaces to Another Instance”</a>.
</p>
<h4><a name="alter-table-row-order"></a>Row Order for MyISAM Tables</h4>
<a class="indexterm" name="idm139663178484320"></a><p>
      <code class="literal">ORDER BY</code> enables you to create the new table
      with the rows in a specific order. This option is useful primarily
      when you know that you query the rows in a certain order most of
      the time. By using this option after major changes to the table,
      you might be able to get higher performance. In some cases, it
      might make sorting easier for MySQL if the table is in order by
      the column that you want to order it by later.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Note
</div>
<p>
        The table does not remain in the specified order after inserts
        and deletes.
</p>
</div>
<p>
      <code class="literal">ORDER BY</code> syntax permits one or more column
      names to be specified for sorting, each of which optionally can be
      followed by <code class="literal">ASC</code> or <code class="literal">DESC</code> to
      indicate ascending or descending sort order, respectively. The
      default is ascending order. Only column names are permitted as
      sort criteria; arbitrary expressions are not permitted. This
      clause should be given last after any other clauses.
    </p><p>
      <code class="literal">ORDER BY</code> does not make sense for
      <code class="literal">InnoDB</code> tables because <code class="literal">InnoDB</code>
      always orders table rows according to the
      <a class="link" href="glossary.html#glos_clustered_index" title="clustered index">clustered index</a>.
    </p><p>
      When used on a partitioned table, <code class="literal">ALTER TABLE ... ORDER
      BY</code> orders rows within each partition only.
</p>
<h4><a name="alter-table-partition-options"></a>Partitioning Options</h4>
<p>
      <em class="replaceable"><code>partition_options</code></em> signifies options
      that can be used with partitioned tables for repartitioning, to
      add, drop, discard, import, merge, and split partitions, and to
      perform partitioning maintenance.
    </p><p>
      It is possible for an <a class="link" href="alter-table.html" title="13.1.9 ALTER TABLE Syntax"><code class="literal">ALTER TABLE</code></a>
      statement to contain a <code class="literal">PARTITION BY</code> or
      <code class="literal">REMOVE PARTITIONING</code> clause in an addition to
      other alter specifications, but the <code class="literal">PARTITION
      BY</code> or <code class="literal">REMOVE PARTITIONING</code> clause must
      be specified last after any other specifications. The <code class="literal">ADD
      PARTITION</code>, <code class="literal">DROP PARTITION</code>,
      <code class="literal">DISCARD PARTITION</code>, <code class="literal">IMPORT
      PARTITION</code>, <code class="literal">COALESCE PARTITION</code>,
      <code class="literal">REORGANIZE PARTITION</code>, <code class="literal">EXCHANGE
      PARTITION</code>, <code class="literal">ANALYZE PARTITION</code>,
      <code class="literal">CHECK PARTITION</code>, and <code class="literal">REPAIR
      PARTITION</code> options cannot be combined with other alter
      specifications in a single <code class="literal">ALTER TABLE</code>, since
      the options just listed act on individual partitions.
    </p><p>
      For more information about partition options, see
      <a class="xref" href="create-table.html" title="13.1.20 CREATE TABLE Syntax">Section 13.1.20, “CREATE TABLE Syntax”</a>, and
      <a class="xref" href="alter-table-partition-operations.html" title="13.1.9.1 ALTER TABLE Partition Operations">Section 13.1.9.1, “ALTER TABLE Partition Operations”</a>. For
      information about and examples of <code class="literal">ALTER TABLE ...
      EXCHANGE PARTITION</code> statements, see
      <a class="xref" href="partitioning-management-exchange.html" title="23.3.3 Exchanging Partitions and Subpartitions with Tables">Section 23.3.3, “Exchanging Partitions and Subpartitions with Tables”</a>.
</p>
</div><br />
        </div>

                <div id="docs-in-page-nav-container">
            <div id="docs-in-page-nav">
                
    <a href="alter-server.html"
        aria-label="Previous" title="Previous: ALTER SERVER Syntax"><span
        class="icon-chevron-left"></span> PREV</a> &nbsp;
<a href="index.html" aria-label="Start" title="Start"> HOME</a> &nbsp;
        <a aria-label="Up" href="sql-syntax-data-definition.html" title="Up: Data Definition Statements"> UP</a> &nbsp;
    <a href="alter-table-partition-operations.html" aria-label="Next"
        title="Next: ALTER TABLE Partition Operations">NEXT <span
        class="icon-chevron-right"></span></a>
            </div>
        </div>
        
         <div id="docs-body-extra">
             
<a class="docs-sidebar-section" href=""><span class="icon-related"></span>
    <span class="text">Related Documentation</span></a>
<div class="docs-sidebar-accordian">
    <div class="text">
        <a href="/doc/relnotes/mysql/8.0/en/">MySQL 8.0 Release Notes</a><br />
        <a href="/doc/dev/mysql-server/latest/">MySQL 8.0 Source Code Documentation</a><br />
        </div>
</div>

    <a class="docs-sidebar-section" href=""><span class="icon-download-thin"></span>
        <span class="text">
            Download
                            this Manual
                    </span>
    </a>
    <div class="docs-sidebar-accordian">
        <div class="text">
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.pdf">PDF (US Ltr)</a>
            - 46.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.a4.pdf">PDF (A4)</a>
            - 46.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-ref-manual-8.0-en-pdf-1-20190611.noarch.rpm">PDF (RPM)</a>
            - 41.5Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.html-chapter.tar.gz">HTML Download (TGZ)</a>
            - 10.6Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.html-chapter.zip">HTML Download (Zip)</a>
            - 10.6Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-ref-manual-8.0-en-html-chapter-1-20190611.noarch.rpm">HTML Download (RPM)</a>
            - 9.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.man-gpl.tar.gz">Man Pages (TGZ)</a>
            - 220.4Kb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.man-gpl.zip">Man Pages (Zip)</a>
            - 325.8Kb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-8.0.info.gz">Info (Gzip)</a>
            - 4.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-8.0.info.zip">Info (Zip)</a>
            - 4.1Mb<br />
                    </div>
    </div>

<a class="docs-sidebar-section" href=""><span class="icon-book"></span>
    <span class="text">Excerpts from this Manual</span></a>
<div class="docs-sidebar-accordian">
    <div class="text">
                <a href="/doc/mysql-backup-excerpt/8.0/en/">MySQL Backup and Recovery</a><br />
                <a href="/doc/mysql-g11n-excerpt/8.0/en/">MySQL Globalization</a><br />
                <a href="/doc/mysql-infoschema-excerpt/8.0/en/">MySQL Information Schema</a><br />
                <a href="/doc/mysql-installation-excerpt/8.0/en/">MySQL Installation Guide</a><br />
                <a href="/doc/mysql-security-excerpt/8.0/en/">Security in MySQL</a><br />
                <a href="/doc/mysql-startstop-excerpt/8.0/en/">Starting and Stopping MySQL</a><br />
                <a href="/doc/mysql-linuxunix-excerpt/8.0/en/">MySQL and Linux/Unix</a><br />
                <a href="/doc/mysql-windows-excerpt/8.0/en/">MySQL and Windows</a><br />
                <a href="/doc/mysql-osx-excerpt/8.0/en/">MySQL and OS X</a><br />
                <a href="/doc/mysql-solaris-excerpt/8.0/en/">MySQL and Solaris</a><br />
                <a href="/doc/mysql-sourcebuild-excerpt/8.0/en/">Building MySQL from Source</a><br />
                <a href="/doc/mysql-reslimits-excerpt/8.0/en/">MySQL Restrictions and Limitations</a><br />
                <a href="/doc/mysql-partitioning-excerpt/8.0/en/">MySQL Partitioning</a><br />
                <a href="/doc/mysql-secure-deployment-guide/8.0/en/">MySQL Secure Deployment Guide</a><br />
                <a href="/doc/mysql-tutorial-excerpt/8.0/en/">MySQL Tutorial</a><br />
                <a href="/doc/mysql-perfschema-excerpt/8.0/en/">MySQL Performance Schema</a><br />
                <a href="/doc/mysql-replication-excerpt/8.0/en/">MySQL Replication</a><br />
                <a href="/doc/mysql-repo-excerpt/8.0/en/">Using the MySQL Yum Repository</a><br />
            </div>
</div>
         </div>

                     
<div id="docs-comments">
    <div class="docs-comments-header"><span class="icon-bubbles"></span> User Comments</div>

    <div class="docs-comments-disclaimer">
        User comments in this section are, as the name implies, provided by MySQL users.
        The MySQL documentation team is not responsible for, nor do they endorse, any of
        the information provided here.
    </div>

    <div id="comment-listing">
    
                    <div class="docs-comment-item" id="c16148">
            <div class="docs-comment-item-header">
                                <span class="icon-chatbubble"></span> &nbsp;
                Posted by
                <span class="docs-comment-name">
                                    Bassem Melek
                                </span>
                on
                November 29, 2018
                                </div>
                            <div class="docs-comment-item-edit"></div>
                <div class="docs-comment-item-text">
                    how to change Referenced column of exist foreign key<br /><br />                        string qCreateDB2 = string.Format(&quot;ALTER TABLE `mrsalesdb`.`purchases_item_seriels` UPDATE CONSTRAINT `FKSer_sitem_ID` FOREIGN KEY (sitem_ID) REFERENCES sales_item(sitem_ID) ;&quot;);<br />
                </div>
                    </div>
                </div>

</div>
              </div>
     </div>

</div>

<script>
$(function() {
    var doc = new $.doc({ 'mobile': $.browser.mobile, 'docId': 1, 'highlight': true });
});
</script>
    

            
        </div>
    </div>

    <footer class="collapsed">
        <div id="footer-bottom">
                                    <div id="footer-collapse">
                <a href="" id="expand-footer"
                    aria-label="Expand Footer"
                    title="Expand Footer"><span
                    class="icon-plus-square"></span></a>
            </div>
                        <div class="footer-contact">
                <div id="footer-contact-icon" style="display: none;">
                    <span class="icon-call-phone"></span>
                </div>
                <div id="footer-contact-numbers" style="display: none;">
                    <strong>Contact MySQL Sales</strong><br/>
                    USA/Canada: +1-866-221-0634 &nbsp;
                    (<a href="https://www.mysql.com/about/contact/phone/">More Countries &raquo;</a>)
                </div>
                <div id="footer-contact-copyright" style="display: inline-block;">
                    <a href="http://www.oracle.com/" aria-label="Oracle" title="Oracle"><span class="oracle-logo"></span></a>
                    &nbsp; &copy; 2019, Oracle Corporation and/or its affiliates
                </div>
            </div>
            <div class="social-icons">
                <a aria-label="Join us on Facebook" title="Join us on Facebook" href="http://www.facebook.com/mysql"><span class="icon-facebook-square"></span></a>
                <a aria-label="Follow us on Twitter" title="Follow us on Twitter" href="https://twitter.com/mysql"><span class="icon-twitter-square"></span></a>
                <a aria-label="Follow us on LinkedIn" title="Follow us on LinkedIn" href="https://www.linkedin.com/company/mysql"><span class="icon-linkedin-square"></span></a>
                <a aria-label="Visit our YouTube channel" title="Visit our YouTube channel" href="http://www.youtube.com/mysqlchannel"><span class="icon-youtube-square"></span></a>
            </div>
            <br class="clear" />
        </div>
        <div id="footer-links">

            <div id="footer-nav"></div>

            <div class="links">
                <ul>
                    <li class="top"><a href="https://www.mysql.com/products/">Products</a></li>
                    <li><a href="https://www.mysql.com/cloud/">Oracle MySQL Cloud Service</a></li>
                    <li><a href="https://www.mysql.com/products/enterprise/">MySQL Enterprise Edition</a></li>
                    <li><a href="https://www.mysql.com/products/standard/">MySQL Standard Edition</a></li>
                    <li><a href="https://www.mysql.com/products/classic/">MySQL Classic Edition</a></li>
                    <li><a href="https://www.mysql.com/products/cluster/">MySQL Cluster CGE</a></li>
                    <li><a href="https://www.mysql.com/oem/">MySQL Embedded (OEM/ISV)</a></li>
                </ul>
            </div>

            <div class="links">
                <ul>
                    <li class="top"><a href="https://www.mysql.com/services/">Services</a></li>
                    <li><a href="https://www.mysql.com/training/">Training</a></li>
                    <li><a href="https://www.mysql.com/certification/">Certification</a></li>
                    <li><a href="https://www.mysql.com/consulting/">Consulting</a></li>
                    <li><a href="https://www.mysql.com/support/">Support</a></li>
                </ul>
            </div>

            <div class="links">
                <ul>
                    <li class="top"><a href="https://dev.mysql.com/downloads/">Downloads</a></li>
                    <li><a href="https://dev.mysql.com/downloads/mysql/">MySQL Community Server</a></li>
                    <li><a href="https://dev.mysql.com/downloads/cluster/">MySQL NDB Cluster</a></li>
                    <li><a href="https://dev.mysql.com/downloads/shell/">MySQL Shell</a></li>
                    <li><a href="https://dev.mysql.com/downloads/router/">MySQL Router</a></li>
                    <li><a href="https://dev.mysql.com/downloads/workbench/">MySQL Workbench</a></li>
                </ul>
            </div>

            <div class="links">
                <ul>
                    <li class="top"><a href="https://dev.mysql.com/doc/">Documentation</a></li>
                    <li><a href="https://dev.mysql.com/doc/refman/en/">MySQL Reference Manual</a></li>
                    <li><a href="https://dev.mysql.com/doc/workbench/en/">MySQL Workbench</a></li>
                    <li><a href="https://dev.mysql.com/doc/index-cluster.html">MySQL NDB Cluster</a></li>
                    <li><a href="https://dev.mysql.com/doc/index-connectors.html">MySQL Connectors</a></li>
                    <li><a href="https://dev.mysql.com/doc/#topic">Topic Guides</a></li>
                </ul>
            </div>

            <div class="links">
                <ul>
                    <li class="top"><a href="https://www.mysql.com/about/">About MySQL</a></li>
                    <li><a href="https://www.mysql.com/about/contact/">Contact Us</a></li>
                                                            <li><a href="https://www.mysql.com/buy-mysql/">How to Buy</a></li>
                    <li><a href="https://www.mysql.com/partners/">Partners</a></li>
                    <li><a href="https://www.mysql.com/about/jobs/">Job Opportunities</a></li>
                    <li><a href="https://www.mysql.com/sitemap.html">Site Map</a></li>
                </ul>
            </div>

            
            <div id="footer-logo">
                <a href="http://www.oracle.com/" aria-label="Oracle" title="Oracle"><span class="oracle-logo"></span></a>
                &nbsp; &copy; 2019, Oracle Corporation and/or its affiliates
                <div class="footer-legal-links">
                    <a href="https://www.mysql.com/about/legal/">Legal Policies</a> |
                    <a href="http://www.oracle.com/us/legal/privacy/index.htm">Your Privacy Rights</a> |
                    <a href="http://www.oracle.com/us/legal/terms/index.html">Terms of Use</a> |
                    <a href="http://www.oracle.com/us/legal/third-party-trademarks/index.html">Trademark Policy</a> |
                    <a href="http://www.oracle.com/technetwork/community/oca-486395.html">Contributor Agreement</a> |
                    <div id="teconsent" style="display: inline-block"><script async="async" type="text/javascript" src="js/notice.js" crossorigin=""></script></div>
                </div>
            </div>

        </div>
    </footer>
</div>

        <script src="js/s_code_remote.js"></script>

        
    
</body>
</html>
